Delete 2 strings from 1 line with sed?

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

How would you do that?

Thanks.

Does "something" always occur before "122344" ?

This removes all line containing both something and 122344

awk '!(/something/ && /122344/)' infile
another something 9998898 34343424
big small something 122121 23323 545454 657676767

Hello,

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.

Thanks,
R. Singh

Thanks guys, I'll test that, and I'm wondering is it possible to use also the sed command?

Try this: something should occur before 122344 strings in order to delete the line

sed '/something.*122344/d' infile

Same as juzz4fun post but with awk

awk '!/something.*122344/' infile