Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

capturing a file line in a variable

Status
Not open for further replies.
Aug 15, 2002
422
US
Hi Folks,

Given a file myfile.txt that contains two lines:

BOM BOM_SRS_DATE BOM_SRS_DATE_STANDARD
CE FND_DATE4 FND_STANDARD_DATE


How would I use awk to extract each line as a variable into my shell script?
Example:

VAR1 = BOM BOM_SRS_DATE BOM_SRS_DATE_STANDARD
VAR2 = CE FND_DATE4 FND_STANDARD_DATE


Any help is much appreciated!!

-pd
 
Try something like this:
Code:
eval `awk '{printf "var%d=%s\n",NR,$0}' myfile.txt`
echo "var1='$var1'\nvar2='$var2'"

Hope This Help
PH.
 
Sorry for the typo:
Code:
eval `awk '{printf "var%d=\"%s\"\n",NR,$0}' myfile.txt`
echo "var1='$var1'\nvar2='$var2'"

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top