开发者

linux command line question

If I have a program that takes a number of files, specified on the command line as input:

myprog file1 file2 file3

and a text file containing the names of those files, one per line, is there a way to run the line above but using only t开发者_运维百科he text file?


It is as simple as using:

myprog $(cat file-name)

And file-name is

cat file-name
file1
file2
file3


Yes. Assuming that the text file contains each file name on its own line, you can run:

cat names-of-those-files.txt | xargs my-program-that-takes-files


myprog `cat filelist.txt`

Cool... you don't even need to convert \n to space.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜