Hi guys, I wonder if it's possible to search for a line containing 2 strings and delete that line and perhaps replace the source file with already deleted line(s).
What I mean is something like this:
sourcefile.txt
line1: something 122344 somethin2 24334 45554676
line2: another something 9998898 34343424
line3: big small something 122121 23323 545454 657676767
and now I'd like to search for a line containg "something" and "122344" which should find and delete just the 1st line.
then the outputfile.txt will contain just the 2 lines without the matched 2 strings:
line1: another something 9998898 34343424
line2: big small something 122121 23323 545454 657676767
Could you please create a script as follows for same.
$ cat test121.ksh
while read line
do
a=`echo $line | grep -i "something 122344"`
if [[ -n $a ]]
then
echo "Line deleted that have something 122344 together."
else
echo $line >> test13
fi
done < "test12"
$
Where test12 kis the file which have all your data and test13 wil be the new file after running the script.
Please get back to me in case you have any queries.