nms
1
Hi,
So basically I have this file containing query output in seperated columns.
In particular column I have the below strings:
news
news-prio
I am trying to grep the string news without listing news-prio aswell.
I tried
grep "$MSG_TYPE"
,
grep -w "$MSG_TYPE"
,
grep "\<$MSG_TYPE\>"
, however none of them worked.
The variable MSG_TYPE is taken as an argument in the script.
Can someone provide an example on how I can achieve this?
What column the string is in?
What separates columns?
A sample file would help as well...
nms
3
A pipe seperates the column
q_1_2|Orange|news|0|0|0|0|43200|43200
The below is an example:
msg_type=`cat $CRONOUTFILE| grep $AFFILIATE | grep "$MSG_TYPE" | awk -F'|' '{print$3}' `
MSG='news'
awk -F'|' '$3 == msg' msg="${MSG}" "${CRONOUTFILE}"
RudiC
5
How about
grep "|$MSG_TYPE|" file
q_1_2|Orange|news|0|0|0|0|43200|43200
Please be aware that he pipe symbol has a special meaning in extended regexes.