in reply to put a newline character after every four lines in a file
With a oneliner:
$ perl -i -ple '$_.="\n" if $. % 4 == 0; close ARGV if eof' -- FILES
Documentation: Command-line switches in perlrun, $. for the current line number, eof in regards to resetting $., and Multiplicative Operators for the modulo operator.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: put a newline character after every four lines in a file
by Anonymous Monk on Feb 24, 2017 at 06:40 UTC | |
by haukex (Archbishop) on Feb 24, 2017 at 15:13 UTC | |
by Anonymous Monk on Feb 24, 2017 at 06:53 UTC |