File content by field into variable
Hi,
A newbie in scripting. I have a file that has only one record with 3 columns TOTALS;11111;12345.67: Just need help in getting field 2 into a variable and field 3 into another variable. Thx |
Field2=$(cut -d \; -f 2 filename)
Field3=$(cut -d \; -f 3 filename) Assuming the file really only contains the one line. If you need to strip the trailing colon off of field 3, then you can do this afterwards: Field3=${Field3%:} |
Quote:
|
Oops. Looks like I made a mistake in my post when typing in the command. The semicolon needs to be escaped with a backslash, not a forward slash. Use "cut -d \; -f 2 filename" for the command.
I've edited my previous post to correct the error. |
All times are GMT -5. The time now is 08:46 AM. |