how to grep for only the values of a specific field
hi let say i have a config file that contain the followng:
MEM_PERCENT=(1 2 3 4) NUM_OPER=(5 6 7 8) how do i grep for only 1 2 3 4 and assign to a variable in my script? i tried content=$(grep -E "MEM_PERCENT" config) but its return the whole line. thanks |
prob not the neatest way but this is how I'd do it:
Code:
content=`cat config | grep "MEM_PERCENT" | sed 's/.*(//g' | sed 's/).*//g'` |
Code:
content=$(awk -F"[\(\)]" '/MEM_PERCENT/ {print $2}' config) Code:
content=`grep "MEM_PERCENT" config | sed 's/.*(//g' | sed 's/).*//g'` |
I said it was sloppy.
|
All times are GMT -5. The time now is 09:00 PM. |