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.
精彩评论