LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-12-2016, 02:01 AM   #1
sub320
Member
 
Registered: Jan 2016
Posts: 116

Rep: Reputation: 3
remove line


I have the below file , I just would like to have a method ( script ) so that to find the line(s) have the string "yyy" , then delete the lines with such string , would advise how to write script ?

thanks


Code:
#vi example.txt

aaa bbb ccc xxxx
aaa bbb ccc yyy
aaa bbb ddd yyy
after run the script ,the output should be as below .
Code:
aaa bbb ccc xxxx
 
Old 02-12-2016, 02:24 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
have you checked grep and/or sed already? You can easily find examples using these tools (to solve similar problems)
 
Old 02-13-2016, 09:33 AM   #3
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
Somehow I feel like going evil...

Code:
sed -i -e 's/.*/aaa bbb ccc xxxx/g' example.txt && sort -u example.txt
it does give the required outcome, right?
 
  


Reply



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
[SOLVED] How to remove a line? mhsahkir Linux - Newbie 5 03-19-2015 07:02 AM
remove the line ust Linux - General 2 11-08-2013 09:21 PM
[SOLVED] Remove line break if next line does not start with "PX" joje47 Programming 8 05-25-2011 08:50 AM
script to remove line ust Linux - Server 2 07-02-2008 05:46 AM
remove the line munna_dude Programming 13 10-04-2007 03:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:29 AM.

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
Open Source Consulting | Domain Registration