2013-01-09 149 views
-2

我一直在尋找所有在整個谷歌的請解釋一下linux的命令:find/tmp -name core -type f -print | xargs的/ bin中/ RM -f

find /tmp -name core -type f -print | xargs /bin/rm -f 

以及我從網本身和解釋的命令也被現在我知道提到there.by了這樣的命令解釋該命令用於在名爲'tmp'的目錄中找到名爲'core'的文件並刪除該文件。我已經使用和檢查了這一點,它是完美的工作。

我的問題是,我無法理解在這個命令中使用的術語,比如-type f和xargs呢? 也如何根據我們的需要生成這樣的命令(顯然不能,除非正確理解),最大的問題是在谷歌寫什麼來獲得這方面的幫助......我的意思是在什麼話題下我可以期待這些。

請幫忙

關於。

+1

使用的人,像「人找到」命令行查看發現的人工,也xargs的。 – auselen

+0

你可以在手冊頁面找到所有的細節。要打印所有信息,「man find」用於查找,「man xargs」用於xargs,「man pipe」用於「|」。谷歌會給你一堆不必要的信息,這些信息會讓你更加困惑,你瞭解基本知識,你可以通過谷歌你的方式。 – WeloSefer

+0

thanx的回覆 我讀過它,但不清楚像「符號鏈接」這樣的一些術語......那是什麼? –

回答

0

這是UNIX的字符串命令:

find   // name of command (in this case, "find") 

arguments to 'find': 
    /tmp  // where to look 
    -name core // name to look for, "core" (optional argument) 
    -type f  // files only (not, eg, directories or files contents) 
       // (optional argument) 
    -print  // output the list to standard output (STDOUT) 

|    // name of command (otherwise known as 
       // 'pipe') this is a little program that 
       // takes the output from a previous process 
       // (in this case, the output from 'find') 
       // and pass it to another process as input 

xargs   // name of command ('xargs') the program 
       // that will accept the output from 'print' 
       // as input (directed by 'pipe'). It provides 
       // a robust way to process indefinitely 
       // long lists by breaking them into smaller 
       // lists and passing each sublist through 
       // to its command argument 

/bin/rm  // name of command for xargs to execute 
       // on its input list ('rm' = remove) 
     -f  // argument to rm, only remove files, not directories. 

,這是UNIX如何工作的,它是由很多與致力於單個任務晦澀的2個字母的名字有點單一用途的程序的。將這些串聯在一起以實現更復雜的任務。

找出任何一個命令做什麼正確的方法是使用「人」命令與問題作爲參數的命令名稱,如

man find 
man xargs 
man rm 

您將獲得描述每個輸入的詳細信息頁面選項和輸出可能性。像'xargs'這樣的名字也很容易google,但可以理解的是'find'不是(也許試試'unix find')。他們中的許多維基百科的網頁...

也許你應該得到一個體面的進入指南UNIX ...

+0

非常感謝大家......這真的是一個很好的幫助 –

+0

'|'是一個操作員而不是命令。當然,請參閱[link1](http://www.gnu.org/software/bash/manual/html_node/Pipelines.html)[link2](http://www.beforever.com/bashtut.htm#pipe) ,這是真的,因爲Bash是GNU/Linux的默認外殼[Link3](http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29)。但是,這可能不適用於另一個shell或系統。 – yeyo