I have a file with 25 single word entries, I need a script to read through the file one line at a time and input the variable phrase into a second script that will generate a individual file based on the variable phrase name. I'm thinking it might require AWK which I'm inexperienced with. or PERL which I have no experience with. Any help would be greatly appreciated.

  • Please try to explain your problem more clearly. What does the first script need to do? What is the relationship between the “single word entries” in the file and the “variable phrases”? What is the structure of the first file? 25 lines, one word per line? All 25 words on one line? A mixture? And where do environment variables fit in? – Scott Aug 21 '13 at 0:01
  • all it needs to do is read each variable or line which in this case is a list of 25 stock symbols in a text file into a second script. there is only one symbol per line or 25 lines. Also the symbols change every 24 hours. – user247138 Aug 21 '13 at 2:43

You can do it with a simple loop:

for entry in $(cat file_with_25_entries); do echo $entry; done

Just replace echo with your script.


If I understood you correctly, you want a script to read lines from a file containing 25 lines (with one "phrase" per line) and create 25 files named after each of these phrases. If this is indeed your use case, you can do

while read -r line;do
    touch "$line" || echo "Couldn't create \"$line\"" && exit 1
done < your_file_here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy