|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
sed and grep
I am stranded with a problem. Please solve. How will you remove blank lines from a file using sed and grep? ( blank line contains nothing or only white spaces). I run the below commands of sed and grep but grep isn't giving output as desired. Why? Code:
sed '/^[ \o11]*$/d' blank grep -v "^[ \o11]*$" blank (there is a space before tab in character class) The above sed command gave desired result but not grep. Why? Also, I am fix at one more place. As, tab is 011 (octal) but in my system the zero of 011 is accepting as o (alphabetic) instead of numeral zero. If I give numeral zero, it won't work. Is it O.K.? A few days back by mistake a system file got deleted becz of which link count is not showing properly. Can this be a reason for the above problem. Waiting eagerly for your valuable replies.
|
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Quote:
Quote:
Code:
sed '/^[<spc><tab>]*$/d' blank I hope this helps. bakunin |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
blank lines and whitespaces lines could be removed using this regex:
sed '/^ *$/d' |
|
#4
|
|||||
|
|||||
|
Quote:
To make it clearer to readers, you could also replace your bracket expression with [[:space:]]. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sed/tr/grep help | flightskoo | Shell Programming and Scripting | 3 | 04-17-2012 05:09 AM |
| use sed or grep? | dixits | Shell Programming and Scripting | 3 | 02-21-2012 01:31 AM |
| help with SED + GREP | 2001.arun | Shell Programming and Scripting | 6 | 06-14-2010 07:43 AM |
| using sed to grep | wxornot | Shell Programming and Scripting | 1 | 01-24-2006 11:43 PM |
| SED and it used with | and grep | Lem2003 | UNIX for Dummies Questions & Answers | 4 | 02-03-2004 01:26 PM |
|
|