Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Trailing spaces to lines less than x characters

by jeffa (Bishop)
on Jun 05, 2015 at 16:45 UTC ( [id://1129227]=note: print w/replies, xml ) Need Help??


in reply to Trailing spaces to lines less than x characters

How about

perl -ne'chomp; printf "%-76s\n", $_' infile > outfile

Updated to correct silliness. Question: why do you need to append spaces to the end? That seems very impracticle ... spaces are usually prepended to such strings.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Trailing spaces to lines less than x characters
by davido (Cardinal) on Jun 05, 2015 at 18:46 UTC

    That should be...

    perl -lne 'printf "%-76s", $_' infile > outfile

    ...otherwise the spaces will get appended after the newline on each existing line, and then another newline will be appended after that.

    Also in-place editing could look like this:

    perl -lni.bak -e 'printf "%-76s", $_' infile

    Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-29 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found