在find之外使用xargs。
Listing 15. Example of using of the xargs tool.
清单15. xargs工具的使用示例。
Listing 14. Example of output from the xargs tool.
清单14.xargs工具产生的输出示例。
So why is there only one line of output from xargs?
为什么xargs只有一行输出?
Listing 13. Example of the classic use of the xargs tool.
清单13. xargs工具的经典用法示例。
If such an error occurs, use a pipe and the xargs utility.
如果出现此类错误,可使用管道xargs实用工具。
The xargs command will not build arbitrarily long commands.
xargs命令不会构建任意长度的命令。
Using the find command with the -exec option or with xargs.
使用带有-exec选项或xargs的find命令。
In Listing 19 we try using find with -exec rather than ls with xargs.
在清单19中我们尝试使用带有-exec的find,而不是带有xargs的ls。
Next, awk reduces the output to the process ID, which you feed into xargs.
接下来,awk只显示输出结果中的进程ID,并将它传递给xargs。
We could use xargs instead, but we already saw problems with blanks in file names.
我们也可以改为使用 xargs,但我们已经看到了文件名中包含空格时出现的问题。
Compared to what you already learned about using xargs, there are several differences.
与前面学习的xargs命令相比,它有几个不同之处。
On the other hand, xargs is rarely used except with other utilities, most often find.
另一方面,xargs除了与其他实用程序(最常见的是find)配合使用外,很少单独使用。
Use the xargs tool as a filter for making good use of output culled from the find command.
使用xargs工具作为筛选器,以充分利用从find命令挑选的输出。
However, when xargs builds the command, it will pass as many parameters at once as it possibly can.
不过,当xargs构建命令时,它将一次传递尽可能多的参数。
Listing 16 shows one way you might pass a directory listing through xargs to a command such as grep.
清单16显示了一种通过xargs将目录清单传递到命令(比如grep)的方法。
By default, xargs delimits input with a space (or newline) to produce a list of files to operate on.
在缺省情况下,xargs将使用空格(或者换行符)对输入字符串进行划分,以便产生可以进行操作的一个文件列表。
Wherever the replacement string occurs in the command you ask xargs to execute, it will be replaced by an argument.
如果xargs将要执行的命令包含有替换字符串,那么将使用参数替换它。
If you run find on such a batch of files and pass the list of results to xargs, the Spaces in the file names cause errors.
如果您对大量的文件运行find命令,并且将结果列表传递给xargs,那么文件名中的空格将会导致错误。
xargs consumes the filenames from find and runs grep -l repeatedly to process every file, no matter how many files are named.
xargs 接收来自find 的文件名并重复运行grep-l以处理每个文件,而不论有多少个文件。
Now we will look at the -exec option of find, which has similar functionality to using find and piping the output to xargs.
现在我们看一下find命令的- exec选项,其功能类似于使用find并通过管道将输出指向xargs。
In Listing 17 we first copy text1 to "text 1" and then show some ways of using a list of file names containing blanks with xargs.
在清单17中,我们首先将text1复制到“text1”,然后显示一些在xargs命令中使用包含空格的文件名列表的方法。
For instance, xargs takes not records but names of files as input, and all of the actual processing is done by some other program.
例如,xargs不是接受记录而是接受文件名作为输入,并且所有的实际处理都是由其他程序完成的。
In the older Linux systems, or on UNIX systems that may still have the limitation, it is useful to know how to use xargs so you can handle such situations.
在更旧的Linux系统或UNIX系统上仍然存在该限制,因此了解如何使用xargs以处理这种问题非常有用。
In its simplest invocation, xargs is like a filter that takes as input a list (with each member on a single line). The tool puts those members on a single space-delimited line.
在最简单的调用形式中,xargs就像一个筛选器,它接受一个列表(每个成员分别在单独的行上)作为输入。
Modern versions of find may be delimited with a + sign instead of a semi-colon, and this causes find to pass as many names as possible in one invocation of a command, similar to the way xargs works.
新的find可能使用加号(+)取代分号(;)作为分隔符,这允许find在一次调用命令时传递尽可能多的名称,类似于xargs。
Xargs reads data from a pipe and runs a specified command for every line read.
xargs命令可从管道中读取数据并为每行读取内容运行指定命令。
Xargs reads data from a pipe and runs a specified command for every line read.
xargs命令可从管道中读取数据并为每行读取内容运行指定命令。
应用推荐