I have a text file which contains a list of items (one for each line) and I need to create, in a given directory, a file for every entry in the said list; each one of these files should be named with a string in the said list. Also, if possible, after the string contained in the text file, a custom text should be appended to the filenames.
Which commands should I use to do that from the command line? I suppose that cat
, grep
and touch
(and maybe xargs
?) should be involved in the process, but after a few trials I still can't find the correct syntax.
Can someone enlighten me about this?
Answer
Say you have list.txt
like this:
file 1
file 2
file 3
You can achieve what you want with:
while read FILE; do touch "${FILE} some string"; done < list.txt
No comments:
Post a Comment