in reply to Append big files
perl -ple "BEGIN{open $to,'>',shift @ARGV;select $to}" destination. +txt source1.txt source2.txt
The -p print each line, -l does automatic lines handling; the BEGIN block shift @ARGV using that file as destination, select print everything to the destination.
PS: if you want something that can print to a destination file or to STDOUT you can modify the above in:
perl -ple "BEGIN{open $to,'>',shift @ARGV and select $to if $ARGV[0]}" # to STDOUT perl -ple "BEGIN{open $to,'>',shift @ARGV and select $to if $ARGV[0]}" + 0 src1 src2 # to file perl -ple "BEGIN{open $to,'>',shift @ARGV and select $to if $ARGV[0]}" + dst src1 src2
PPS: maybe this is more intellegible
perl -ple "BEGIN{open $to,'>',shift @ARGV and select $to unless $ARGV[ +0] eq 'STDOUT'}" # to STDOUT perl -ple "BEGIN{open $to,'>',shift @ARGV and select $to unless $ARGV[ +0] eq 'STDOUT'}" STDOUT src1 src2
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Append big files -- oneliner
by BrowserUk (Patriarch) on Sep 15, 2016 at 11:58 UTC |