This is how I did to extract the first 100000 lines from my big xml file (2gb):
head source.xml -n 100000 > part.xml
How can I keep splitting them to 100000 line (or specific file size chunks) until the whole file is separated?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You could use
split -l lines_per_file --additional-suffix=.xml source.xml part
This will read the file
source.xml and split it into chunks of
lines_per_file lines each. The result will be written into a series of files
If you want to use another number of suffix characters, you can use the
-a option to specify a number, eg.
-a 1 to name the files
If you want to split to file size chunks instead of line counts, you can use
-b size_in_bytes instead of
Please note that the resulting files will most likely be invalid XML files (unless you happen to get one file in return, ie. your input had too few lines/bytes to get split).