Search pattern and assign to Variable
Assalam o Alaikum!
I used this command to search particular pattern from file: grep -n "em16" abc.txt --> em16 value1d 234 I want to assign this random value "234" to variable? for every time this value changes, I want to filter out other text and want this random value 234 to be assigned to variable. thanks! |
If that's exactly one space between the fields, then
Code:
a=$(grep -n "em16" t.t|cut -d' ' -f3) Code:
b=$(grep -n "em16" t.t|awk '{print$3}') |
Thanks dear, this helps me to proceed ahead
|
There's no need to combine grep and awk (or grep and sed). Just use the one that has the greater flexibility.
Code:
b=$( awk '/em16/ { print $NF }' abc.txt ) |
All times are GMT -5. The time now is 06:41 PM. |