I have got nine text files in a directory, each has 1000 lines. I want to take the first 500 lines from each, then write all of them in order to another text file, and take the rest (the last 500 lines) from each one to do the same I do before.
awk '{if (NR<=500) {print}}' 1.txt > 2.txt # I do it 9 times, then I use cat to append.
awk '{if (NR>500) {print}}' 3.txt > 4.txt
or
awk 'NR>500' 3.txt > 4.txt
I did it with awk, but I want to learn Perl instead.
1 Answer