LinuxQuestions.org
Visit Jeremy's Blog.
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 09-22-2011, 03:16 AM   #1
Jae-Yong Yoo
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Rep: Reputation: Disabled
Automatically deleting a line using find, grep, and vim


Hello,
would it be possible the following?

Imagine there are multiple files, for instance
this.c
that.c
...

In these files, you want to find a line that contains #include <stdbool.h> and delete the line.

Is it possible to do that using find, grep, vim or else?

Jaeyong
 
Old 09-22-2011, 04:34 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,506

Rep: Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890
Else would be sed.
 
Old 09-22-2011, 04:45 AM   #3
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103
Further Clarification -->

sed -i '#include <stdbool.h>/d' this.c

The above command will delete those lines & write to the file. The link below is further info.


http://www.thegeekstuff.com/2009/09/...itute-command/
 
Old 09-22-2011, 05:06 AM   #4
Jae-Yong Yoo
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Original Poster
Rep: Reputation: Disabled
Thanks
 
  


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
Fortran. How to automatically find the starting and ending line of desired variable parekhharsh_j Programming 5 06-24-2011 12:37 PM
Fortran. How to automatically find the starting and ending line of desired variable parekhharsh_j Programming 2 06-23-2011 07:36 AM
shell script find a line and the next line (grep?) metalx1000 Programming 5 07-24-2007 08:41 PM
Command line tool to find(1) or grep(1) faster? rsheridan6 Linux - Software 2 02-18-2006 03:50 PM
PHP: what's wrong with this line (shell_exec, find, xargs, grep)? J_Szucs Programming 3 11-19-2003 07:44 PM


All times are GMT -5. The time now is 02:02 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration