Have you ever want to split a large file into several small files? I’ve face this problem few days ago. I need to split a large file (3GB log file) into several smaller file where i can read it using normal text editor.
To split large file into several smaller files, you can use split command in linux. Just follow the steps below and you will be able to split large file into smaller files.
-
in your shell key in
$ split –bytes=1m /path/to/large/file
/path/to/output/file/prefix - Done. You just split your large file into several smaller files
* You can change the output file size by changing the –bytes=1m to your preference. You can use b, k, or m. b represent bytes, k represent kilobytes, m represent megabytes.
To restore the original file, you can use cat command.
To join all the smaller file to restore the original file type:-
$ cat prefix* > NEWFILENAME




please give an example
Thanks! One of the most useful commands I’ve found!
Your article is helpful, but slightly wrong. It should read :
split -–bytes=1m /path/to/large/file /path/to/output/file/prefix
an extra – in front of bytes..
Bipin Bahuguna: if it’s text file then probably u can compress it using tar gz. then split into smaller files.
i don’t have experience working with such a large file yet. so the solution might not be working, anyway it’s always good to try.
Good luck
Hi,
My application created up to 400gb log file.
is there any way to compress it .any suggestion?
Thanks,
Bipin Bahuguna