Re: Scripting question

Gordon Messmer <[email protected]>
Newsgroups gmane.linux.redhat.release.psyche
Message-ID <[email protected]>
Leonard Miller wrote:
>>>>[email protected] 07/11/03 09:38AM >>>
> 
>> cat file | grep -v ^\    > file_nospace         (that's a ^ followed by 
>> a \ followed by a space)
>> mv file_nospace file
 >
 > Thanks Alan,
 > That worked great.  Now let me ask you this.
 > I have another file with blank lines - no space or tabs, just
 > carriage returns.
 > Can I use that same line to remove those blank lines?


$ grep -v '^$' file > file_nospace

You can also accomplish both of your filters in one path like this:

$ egrep -v '^([[:space:]]|$)' file > file_nospace

That command will eliminate lines where the beginning of the line is 
followed either by whitespace or by the end of the line.



-- 
Psyche-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/psyche-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.