This is very common problem in applications to generate big logs file because not properly configure the logging approach for log file size, indexing and archival some time these logs files in GB. When developer need to troubleshoot any issue then face problem to open these files in notepad or notepad++.
The good approach ids to download this file in your local and split in equals logs size files.
There are many solution to split the log/text file but below solution help to all the developers with minimum effort.
Follow step 3 in case you are already having git bash in your local
- If you don’t have Git/Git Bash, download at https://git-scm.com/download
- If you lost the shortcut to Git Bash, you can run it using
- Open the git bash where you place the big log/text file. Run the below commands as per your requirement.
Split the file of 100 MB each
split largeFile.txt -b 100m
Here you can decide size as m for mega byte, b for byte with size. and use attribute -b for size.
If you have noticed from screen shot all the logs files size is same.
Split the file of 1000 line each
split largeFile.txt -l 1000
Here attribute -l represent for number of lines.
If you have noticed all the files size are different because depend on character in line.
In the above examples the files are splitting by prefix as x and continuously increasing alphabets. Incase you want logical name with indexing follow below approach.
Split the file with Suffix and Prefix
In this approach you will learn about the logical file name as prefix and indexing.
split myLargeFile.txt myLog_ -l 20000 -a 3 -d
In the above example myLog_ is prefix of generating file, -l is use for number of lines in each file, 3 -d is use for three digit indexing of file names.
In this this post you have learn about the problem of large log files and solution to split in equal size with different approaches.