开发者

linux command line question

开发者 https://www.devze.com 2023-02-22 00:35 出处:网络
If I have a program that takes a number of files, specified on the command line as input: myprog file1 file2 file3

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

精彩评论

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