Pandee
September 22, 2011, 11:47am
1
I've a file Test.log. The contents of the file is as follows :
sdadadasdsa
***--aaaaaaaaaaaaaaa
kjsdfjdsakfjskfjasd
***--sdfasdfasfsdf
***--fdsfbfgbhgh
dfgvfgbgbbg
I want to run a script that should delete all the lines that doesnot start with '***--'
I ran the below script :
nawk 'match($0,"***--") != 0 {print $0}' Prcs_Schdlr_Check.log > Result.log
It is giving the below message :
nawk: illegal primary in regular expression ***-- at **--
source line number 1
context is
>>> match($0,"***--") <<<
Could some one please tell me what am doing wrong?
I'm running the script on SunOS 5.10
sed '/^***--/d' Prcs_Schdlr_Check.log > Result.log
OR
nawk '!/^\*\*\*--/' Prcs_Schdlr_Check.log > Result.log
Pandee
September 22, 2011, 12:02pm
3
Hi vgersh99,
Thanks a lot for your quick response.
The code that you gave is deleting all the lines that start with '***--'
But I wanted it in the other way. It should delete all the lines except those starting with '--'. In other words, the output should have only the lines starting with ' --'
Regards,
Pandee
sorry:
nawk '/^\*\*\*--/' myFile
sed -n '/^***--/p' myFile
edgarvm
September 22, 2011, 12:05pm
5
sed -n '/^***--/p' yourfile
Pandee
September 22, 2011, 12:16pm
6
It worked !!!
Thanks a lot guys for your lightening quick responses...