get fields using awk
I have a shell local variable like this:
Quote:
Quote:
Quote:
Thanks, |
Does AWK have the ability to assign fields? (The man page will tell you)
This: Quote:
But--awk returns field values with--eg-- print $1, so I'm not sure what the quoted syntax does. How about this: Code:
a=18 |
Code:
c:~$ value=18:46:52 |
Thanks alot. It's working....!
|
Quote:
Code:
echo $value | awk 'BEGIN{FS=":"}{a=$1;b=$2;c=$3}' |
If shell variables are to be set and awk is preferred then awk can be used to write shell variable assignments for the shell to execute using eval
Code:
#!/bin/bash Code:
#eval $( echo "$value" | /usr/bin/awk -F ':' ' |
Quote:
Better to store the original IFS away, then restore it when you're finished. Code:
oldIFS="$IFS" |
Quote:
|
Hmm. I must've missed your last response on that thread somehow. I know it was that thread I was thinking about that prompted me to post here. So I guess it's safe. But it would still be nice to confirm it 100%.
|
Quote:
|
All times are GMT -5. The time now is 08:07 PM. |