LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How do I remove all lines starting with "-CONFIG_" from a file ? (https://www.linuxquestions.org/questions/linux-kernel-70/how-do-i-remove-all-lines-starting-with-config_-from-a-file-836317/)

Glenn D. 10-05-2010 08:45 AM

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

druuna 10-05-2010 09:05 AM

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.

kurumi 10-05-2010 09:07 AM

Code:

ruby -i.bak -ne 'print unless /^-CONFIG/' config.diff

David the H. 10-05-2010 09:20 AM

Code:

grep -v '^-CONFIG_' .config.diff > newfile
mv newfile .config.diff


vinaytp 10-05-2010 09:36 AM

Hi Glenn D,

Same using perl

Code:

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


All times are GMT -5. The time now is 08:45 PM.