Introduction
Many a times we are having to deal with the very large files, be it the logs from the server like catalina.out or any other huge sql files or csv or text files.
These are some artifacts that could have been generated in the server or might contain the data. There might not have been detailed logging systems that can do a RollingFile like appender that can get the files into smaller chunks for us to use easily. In some cases these could be large data which is hard to split into multiple chunks in an export mechanism.
Problem Statement
When we try to open them in an editor like Notepad / Notepad++ / VS Code, we normally run into memory issues and the application gets frozen.
At times, in case of windows, we might have to go to Task Manager , find the application and then End Task so that we can use the other apps or to allow that particular application to be usage
Solution
In this post, we explore on using git bash a tool. We normally use a git bash command line interface that can be used to perform the git operations. In this case we can use a useful command in git bash that can help us here. Open git bash from the windows or linux system.
Assuming that we have a large file to name as largefile.ext which we can think of as having more than 1 GB of size and that we wanted it to be split into smaller chunks of 300mb. The below command can be used from the command line
split largefile.ext -b 300m
Once run, we can use a dir incase of a windows OS or a ls (or) ls -al on a linux system that can help us view the list of files that were created in the process of splitting.
Remarks
I have been trying to literally open server logs by downloading them from server and given that they were very huge, I had to try with different editors and even if the file was opened, a search could take minutes or move the application (editor) into a frozen state which can take mins to unfreeze or might have to end task and restart.
This solution literally saved a lot of my time. Hope it does for the reader as well
Comments
Post a Comment