LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-05-2010, 08:45 AM   #1
Glenn D.
Member
 
Registered: May 2009
Location: ACT - Australia
Distribution: Opensuse x86_64 (Latest)
Posts: 132

Rep: Reputation: 26
How do I remove all lines starting with "-CONFIG_" from a file ?


Hello.
How do I remove all lines starting with "-CONFIG_" from a file ?
There are a 100 or so lines to remove for example see below.
Thanks Glenn

# /bin/cat .config.diff | grep -i "\-CONFIG\_" | tail
-CONFIG_VME_BUS=m
-CONFIG_VME_CA91CX42=m
-CONFIG_VME_TSI148=m
-CONFIG_VME_USER=m
-CONFIG_VMIVME_7805=m
-CONFIG_VT6655=m
 
Old 10-05-2010, 09:05 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Something like this:

sed -i.bak '/-CONFIG_/d' infile

The -i switch changes in place an creates a back-up with the .bak extension.

Hope this helps.
 
Old 10-05-2010, 09:07 AM   #3
kurumi
Member
 
Registered: Apr 2010
Posts: 228

Rep: Reputation: 53
Code:
ruby -i.bak -ne 'print unless /^-CONFIG/' config.diff
 
Old 10-05-2010, 09:20 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Code:
grep -v '^-CONFIG_' .config.diff > newfile
mv newfile .config.diff
 
Old 10-05-2010, 09:36 AM   #5
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

Rep: Reputation: 55
Hi Glenn D,

Same using perl

Code:
 perl -ni -e  'print unless /^-CONFIG_/' cat.config.diff
Warm Regards,
 
  


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
how can I "cat" or "grep" a file to ignore lines starting with "#" ??? callagga Linux - Newbie 7 08-16-2013 06:58 AM
[SOLVED] Script to remove lines in a file with more than "x" instances of any character ? pissed_budgie Programming 12 10-08-2010 08:16 PM
bash - how to remove lines from "FILE_A" which presents in "FILE_B" ? Vilmerok Programming 4 03-13-2009 04:27 AM
"How to read lines from a file" sharath.bv Linux - Newbie 5 02-01-2008 07:47 AM
gs not starting "CRIT: rangecheck in get" some TTF file duryodhan Slackware 2 09-30-2007 11:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:19 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
Open Source Consulting | Domain Registration