ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there any file utility in Linux to truncate from beginning of the file. I have a growing binary file and I need to delete part of it whenever it reaches pre-specified limit. I need to delete the old data. Please let me know how can I handle it.
There's a command to truncate a file by keeping the start of it only (and keeping the same inode): truncate.
There's a command to put the start/end of a file into another file: head/tail.
But I don't think there is any command to keep only the end of a file into the same inode…
Wouldn't you need to start your new file from some kind of record boundary in the original file? Anyway, how about tail -c xx >new file
where xx is the number of bytes you want to keep.
I have been using-- echo | cat fileName | command.....(what ever code) > samefilename. this will overwrite the same file will what ever altercations you made.
It is work. I used tail with -c to solve my problem. Thank you so much.
I'd like to ask, let said I have few Mbytes data in the file.txt, the 'tail' still can work to redirect output to out.txt (up to how many bytes tail can support)?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.