dimanche 1 mars 2015

use "read" command to pass lines as positional parameters to a shell script


The following file runs, but not doing anything, yet it does not error....



while read dates; do ./avg_hrly_all_final.sh ${dates}; done < ./dates_all.csv


I have a list of dates in "dates_all.csv" that have the following form:



2005 01
2005 02
2005 03


And the script I am calling "avg_hrly_all_final.sh" works by passing it 2 positional parameters, example:



./avg_hrly_all_final.sh 2005 01


FOLLOW-UP



xargs -n2 ./the_script.sh <./dates_to_pass.csv

OR

while read dates; do ./the_script.sh ${dates}; done <./dates_to_pass.csv


work, just make sure the dates of the file being passed is of the same "End of Line" variety as the machine you are running the command on expects ;)



Aucun commentaire:

Enregistrer un commentaire