I have a text file named crn.txt
containing text below:
9 1 * * 3,6 /opt/testtingtools/kos/bin/cos.sh
55 23 * * * /opt/testtingtools/tqdaily.sh 2>>/opt/toolcheck/extract.err
50 11 * * 6 /opt/devtools/toolbox/toolcheck.sh >>toolcheck.log 2>&1
55 23 * * 5 /opt/devtools/toolbox/reset.sh >>/opt/toolcheck/log/reset.log
56 23 * * 6 /opt/prdtools/tqweekly.sh 2>>/opt/checktool/extract.err
30 11 * * 6 /opt/proadtools/tool.sh >/opt/checkingtools/tool.log 2>&1
I need to delete the lines containing a word testtingtools
and update crn.txt
so that the output looks like this:
50 11 * * 6 /opt/devtools/toolbox/toolcheck.sh >>toolcheck.log 2>&1
55 23 * * 5 /opt/devtools/toolbox/reset.sh >>/opt/toolcheck/log/reset.log
56 23 * * 6 /opt/prdtools/tqweekly.sh 2>>/opt/checktool/extract.err
30 11 * * 6 /opt/proadtools/tool.sh >/opt/checkingtools/tool.log 2>&1
I am using the command
sed '/testtingtools/d' crn.txt 2>&1 | tee crn.txt
It works in bash or the command line, but not inside the script. I am using unix server (sun solaris).
One more command working in linux but not in unix:
echo "$(sed '/testtingtools/d' crn.txt)" > crn.txt
"Not working" means it is not deleting a particular line, it empties the entire file when I use the code inside the script. But when I use the code in command line, it deletes the line containing testting word from crn.txt
.