Split a file into two files at a given line

Solution 1:

A bit tighter solution:

(head -100 > f1.txt; cat > f2.txt) < input.txt

Solution 2:

Use awk, so that you need to make just one pass through the input file. The following assumes you want the first 122 lines in the first file, and the remainder in the second.

awk 'NR < 123 { print >> "top_file"; next } {print >> "bottom_file" }' file_name