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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting a variable (using awk?)

Status
Not open for further replies.

pd123

Programmer
May 22, 2001
48
GB
In a shell script I have a variable

con1 = "filename,table"

I want to parse this string and split at the ',' to create 2 new variables for each value

eg.
Store 'filename' in a variable and 'table' in a variable

Thanks.
 
One method would be ...

VAR1=$(echo $CON1 | cut -d, -f1)
VAR1=$(echo $CON1 | cut -d, -f2)

Greg.
 
One method would be ...

VAR1=$(echo $CON1 | cut -d, -f1)
VAR2=$(echo $CON1 | cut -d, -f2)

Greg.
 
I wasn't sure on the best place to post it.

Thanks anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top