Re: Scripting question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 11 Jul 2003, Leonard_Miller@xxxxxxxx wrote:
> I have a file with over 38000 lines in.  Some of the lines have a
> space at the beginning and I can delete those lines.  Is there a
> way using a script or vi that I can delete the lines that begin
> with a space?

If you mean just a space character (this can be done with a regex, but
index() should be faster):

perl -n -i -e 'print unless 0 == index($_, " ")' FILE

If you want to check space characters as Perl knows them (space,
tab) use the \S regex class (non-whitespace):

perl -n -i -e 'print if m/^\S/' FILE

This will edit the file in place.  You can make a backup with -i.bak
instead of -i; read "perldoc perlrun" for more details.

Ted


-- 
Psyche-list mailing list
Psyche-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux