samedi 28 février 2015

Use lines in a file to produce string and file name


I have a file, foo.txt, that has a folder name on each line:



folder_1
folder_2
folder_3


And I'd like to do something like this:



cat foo.txt | xargs -I {} echo 'function {}() { return stuff; }' > {}/function.js


In other words, I'd like to read a file line by line, then use each line to both create a string and create the name of the file in which the string is stored.


How does one do something like this from the command line in bash?



Aucun commentaire:

Enregistrer un commentaire