lundi 5 janvier 2015

iterate over file and send lines as positional parameters to another file


I would like to iterate through a file containing dates (named dates.txt) in the following format:



2009 08 03 08 09
2009 08 03 09 10
2009 08 03 10 11
2009 08 03 11 12
2009 08 03 12 13
2009 08 03 13 14


And pass each field of each line as a positional parameter to another script.


ie: the other script is executed by putting the following at the command line:



$ . the_script 2009 08 03 08 09


I have tried for i in $(./dates);do echo ${i};done


but get:



./dates: line 1: 2009: command not found
./dates: line 2: 2009: command not found
./dates: line 3: 2009: command not found
./dates: line 4: 2009: command not found
./dates: line 5: 2009: command not found
./dates: line 6: 2009: command not found


from this i can tell it is working through each line but perhaps getting hung up on each field?


Because of the above, I have yet been able to figure out how to pass the read lines as positional parameters to the other script. Not sure where to work it in either? Help, please!



Aucun commentaire:

Enregistrer un commentaire