Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> OS >> Unix >> Shell >> bash >> How use while and read to process data from an input file

 

 
## Example 1 - /var/tmp/titles.txt contain mutiple lines of multi-word strings
## to process each line as a single argument i.e. for the script

while read -r line;do echo ./yourscript.sh "$line";done < /var/tmp/titles.txt


## Example 2 - read selected parameters from a comma separated file and run a script with that parameter as argument

cat /var/tmp/data.txt
12588,ca010001
12592,ca010002
12605,ca010003
12627,ca010004
12639,ca010005

while IFS=, read arg1 arg2;do echo "runsomescript.sh $arg2";done < /var/tmp/data.txt
runsomescript.sh ca010002
runsomescript.sh ca010003
runsomescript.sh ca010004
runsomescript.sh ca010005
runsomescript.sh ca010006


[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]