Hi,
i want to replace the following lines in such a way that if the word merge exists in first column it must replace the 3rd column as M and if parse exists in first column then the last column must P, if neither it must mark it as X. I have tried the solution using awk, but it is saying nawk:empty regular expression
Input file:
INDmerge1 <dns > data
INDparse2 <dns > data
IND2 <dns > data
Result file:
INDmerge1 <dns > M
INDparse2 <dns > P
IND2 <dns > X
I can't see an "empty regular expression" in your attempt, except if $HOSTNAME doesn't expand. Do you get the quoted error message with above? parser won't match your sample file, and the latter has > as third field.
Try
awk '{$4 = ($1 ~ /merge/)?"M":($1 ~ /parse/)?"P":"X"} 1' file
INDmerge1 <dns > M
INDparse2 <dns > P
IND2 <dns > X
Yes, you are right! if i'm executing this bit of code standalone it doesnt throw any errors! however when this is plugged into a startup script it is giving that empty regular expression error.
Thanks a lot for you prompt reply.
I'll try the snippet you have suggested and let you know how it went!
--- Post updated at 11:58 AM ---
Unfortunately RudiC i'm getting this error now
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1