On Tuesday 06 June 2006 01:13, John W. Krahn wrote:
[ few example commands ]
> > I'm accustomed to some of those.  But how do I or is it possible to file
> > slurp on the command line, substituting \n+ with \n
>
> It is explained in the perlrun document for the -0 (zero) switch.
>
> perldoc perlrun

Too cryptic -- IOW I'm not "high enough expertise in the command line 
department" to be able to understand/grasp from (any) of  that.  (I tried)  I 
need simpler example, explanation -- that one be too high and too busy (for 
me, now).

Next I looked perlfaq6

How can I pull out lines between two patterns that are themselves on different 
lines? 

[ snip ]

 If you wanted text and not lines, you would use 

    perl -0777 -ne 'print "$1\n" while /START(.*?)END/gs' file1 file2 ...

perl -0777 -ne 's/\n+/\n/g' rsync_sl_log.txt

^^ my 1st attempt, didn't work

perl -0777 -ne 's/\n+/\n/g' while <> rsync_sl_log.txt

^^ 2nd attempt, didn't work ^^

perl -0777 -pne 's/\n+/\n/g' rsync_sl_log.txt

^^ 3rd -- aha!!! prints to screen with extra \n's removed!!!!!!!

perl -0777 -pne 's/\n+/\n/g' rsync_sl_log.txt > rsync_sl_log.txt.new

^^ 4th attempt.  Bingo!!!!  Works!!!!!

Though I'm unsure if I'm attempting to mix shell and Perl there (bash shell 
redirection operator: > redirect STDOUT to a file)

Though it works, does anyone have any further refinement ideas?

Thanks.

-- 
Alan.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to