Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Making my file all one line

by ehdonhon (Curate)
on Jun 06, 2003 at 01:25 UTC ( [id://263575]=note: print w/replies, xml ) Need Help??


in reply to Making my file all one line

/usr/bin/perl -pe 'chomp' theFileName

Replies are listed 'Best First'.
Re: Re: Making my file all one line
by jmcnamara (Monsignor) on Jun 06, 2003 at 08:47 UTC

    Unfortunately that joins words on sucessive lines together. Using the input given above:
    $ perl -pe 'chomp' file line one line infoline two infoline threemore lines etc

    --
    John.

      Yup. Good point.

      perl -pe 'chomp; s/(\S)\s*$/$1 /;' file

      The other thing I failed to mention is if you actually want to alter the file and not just dump to the screen, you would want to run 'perl -pi -e'.

      Update: jmcnamara msg'ed me and correctly pointed out that my previous regexp didn't work at all, and if it did it would have also created one space for every blank line. :(

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://263575]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-19 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found