LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-14-2014, 09:59 AM   #1
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 231

Rep: Reputation: 5
sed not working as advertised


I need to remove a line in a file that contains a word within the line. I know how to do this with grep, but this example was on a site that was also supposed to do this in place:

sed -i -e '/word/d' <f1> # delete line containing 'word' in file in place

What this does is delete the 'word' out of the line, not delete the whole line.
Is this possible to do with sed in place?

Thanks
 
Old 07-14-2014, 11:06 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,967

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
What version of sed are you using? In any version I've seen, that deletes the whole line. Please show an example.
 
Old 07-14-2014, 03:05 PM   #3
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 231

Original Poster
Rep: Reputation: 5
GNU sed version 4.2.1

I tried it again with a test file and it did indeed remove the whole line. It only removes the word in certain files. Apparently the file type makes a difference. The file looked looked like a text file, but I could only get it to remove the search text.
 
Old 07-15-2014, 09:41 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,255

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
If I were a betting man I would say the files where it behaves unusually are created on Windows as sed has no concern about the file assuming it is regular text
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sbrk() does not work as advertised? kornelix Linux - Software 10 01-23-2014 11:00 AM
Followed Code in Mag, LED Lights Not Working As Advertised Resmi Programming 8 10-09-2009 11:48 AM
SED - minor changes work - Larger doesn't (working and non working code included) Nimoy Programming 17 09-22-2007 05:34 PM
Recognized CPU less than advertised cwej Ubuntu 6 04-09-2007 05:08 PM
changing Apache advertised name ddaas Linux - Networking 2 03-20-2006 11:35 AM


All times are GMT -5. The time now is 03:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration