?
Solved

Need sed help

Posted on 2014-04-08
5
Medium Priority
?
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 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

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 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