How to split log file into two without keeping the original file?

Tek Nath :

I have server log that is around 36GB and there is no more space left in the server. I want to split the file into parts and move the to another storage. Any solution? Looking for help.

Tané :

You can count the lines of your log with wc -l, and then use sed for split it in the half. Example, for a log with 100 lines:

sed -i '1,50{w file.log.1
d}' file.log

"1,50" is the range of lines

"w" write the deleted line to a file.log.1

"d" delete the lines in file.log

I hope this helps

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=6641&siteId=1