Need sed help

I need to know how to delete a line using a wildcard using sed.  The line begins with
!R! BARCODE.  The rest of the line can varies depending on the item.
So how do I tell sed to delete the !R! BARCODE and everything afterwards to the end of the line.  I don't want to actually remove the line, just all the test on the line that begins with !R! BARCODE.
9thTeeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
woolmilkporcConnect With a Mentor Commented:
sed 's/^!R! BARCODE.*//' inputfile > outputfile

This will create a changed "outputfile" leaving "inputfile" as is.

If your sed supports it you can use the "-i" flag to change "inputfile" in place and create an unchanged  backup file "inputfile.bak" in the same go:

sed -i.bak 's/^!R! BARCODE.*//' inputfile
0
 
tel2Commented:
> The line begins with !R! BARCODE.
> I don't want to actually remove the line, just all the test on the line that begins with !R! BARCODE.


So do you want to be left with a blank line, 9thTee?
0
 
9thTeeAuthor Commented:
Yes tel2, a blank line.
0
 
tel2Commented:
In that case, woolmilkporc's solutions should work for you.
0
 
9thTeeAuthor Commented:
Perfect!
0
All Courses

From novice to tech pro — start learning today.