I want to reduce the log file size to the particular minimum size
I tried the truncate command as below
$ truncate -s 20M log filename
But when I check the truncated file it truncates the recent logs and keeps the old logs
When analyzing further I found the tail and head commands. But the problem is when I use the head command is working and when I use tail command it saves the content in the human not readable format like @@@@@@@@@@@
.
$ head -c 10M logfile > newfile
(it saves the head of the file as mentioned size)
$ tail -c 10M logfile > newfile
(It saves the content which cannot be readable)
Now I want to truncate the large file which removes only starting of the file but not the ending of the file and if possible it should be in one command without creating another file as head and tail Can anyone guide me on this? Thank you!