Splitting big files (Rails log files) in Linux command line

Problem
You want to examine some big log files (ie Rails production files), on the command line in Linux but they are quite big.

Solution
You can use cat and grep to look for a specific part in the log files. You can also use grep with the A and B parameters to specify how many lines you want to include before and after the search text, but maybe you want to have chunks of the logs to examine. In that case you can use split to split them up in smaller files:

split --bytes=10M input_log_file.log [output_files_or_directory]

In that case you will be splitting your log file on size (–bytes variable), so you can decide depending on the total size of the log file how many files you want. The output files or directory is optional and if you leave it empty it will create the files in your current directory.

You can also split by the number of lines you want in each file like:

split --lines=15000 input_log_file.log [output_files_or_directory]