Solved

Need sed help

Posted on 2014-04-08
5
354 Views
Last Modified: 2014-04-08
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.
0
Comment
Question by:9thTee
  • 2
  • 2
5 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39987309
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
 
LVL 12

Expert Comment

by:tel2
ID: 39987313
> 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
 

Author Comment

by:9thTee
ID: 39987321
Yes tel2, a blank line.
0
 
LVL 12

Expert Comment

by:tel2
ID: 39987326
In that case, woolmilkporc's solutions should work for you.
0
 

Author Closing Comment

by:9thTee
ID: 39987585
Perfect!
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question