Solved

Need sed help

Posted on 2014-04-08
5
348 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 11

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 11

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Oracle Finace 3 48
Powershell regex followup 13 69
home folder path for users 4 47
Nmap how to find wich type of socks is this? 4 71
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now