DEV Community

MuthuKumar
MuthuKumar

Posted on • Updated on

14 MB log file and you want to split it into multiple 5 MB files using Linux commands

If you have a 14 MB log file and you want to split it into multiple 5 MB files using Linux commands, you can use the split command. Here's how you can do it:

split -b 5M yourlogfile.log prefix_
Enter fullscreen mode Exit fullscreen mode

In this command:

  • split is the command used to split files.
  • -b 5M specifies that you want to split the file into chunks of 5 MB each.
  • yourlogfile.log is the name of the input log file you want to split.
  • prefix_ is the prefix you want to use for the output files. The command will generate files named prefix_aa, prefix_ab, and so on.

After running this command, your log file will be split into multiple 5 MB files with the specified prefix. If you have a total of 14 MB of data, you will get three files: prefix_aa (5 MB), prefix_ab (5 MB), and prefix_ac (4 MB). The last file will be smaller if the input file size is not evenly divisible by 5 MB.

Top comments (0)