Post 9qbHS8XRt1F3kyr1tI by phil@elekk.xyz
 (DIR) More posts by phil@elekk.xyz
 (DIR) Post #9qarkbOqioj5flybFQ by nitox@fosstodon.org
       2020-01-02T14:33:38Z
       
       0 likes, 0 repeats
       
       Hi guys,Does someone know how to 'truncate' a text file in reverse? Instead of removing everything at the end of the log file, you do it at the start.#nix #geeks #shell #commands
       
 (DIR) Post #9qasOVJOmANENISBEG by Clifford@social.garwood.io
       2020-01-02T14:40:49Z
       
       0 likes, 0 repeats
       
       @nitox You can remove lines  from the beginning of a file with: sed 1,5d $FILENAME1 and 5 are start and end line numbers. If we are just nuking the contents of a file but want to retain the inode allocation, you can just do the following:echo > $FILENAMEThis is particularly handy when dealing with a log file for a running service that isn't rotating log files properly. Hopefully this is what you are looking for 😬
       
 (DIR) Post #9qavIFYyiSPDejRygi by nitox@fosstodon.org
       2020-01-02T15:13:20Z
       
       0 likes, 0 repeats
       
       @Clifford i know how to nuke it xD i like the truncate because it removes everything to left only the amount you decide, but it keeps the first N bytes, not the last ones.
       
 (DIR) Post #9qbECD8QjHetW5rmK0 by alexshendi@mastodon.technology
       2020-01-02T18:45:05Z
       
       0 likes, 0 repeats
       
       @nitoxtail -n +11 <file>should do the job, i.e. printing all of the file except for the 11 first lines.Hope that helps!
       
 (DIR) Post #9qbFLXEhSm9IQ4oE1Q by nitox@fosstodon.org
       2020-01-02T18:58:01Z
       
       0 likes, 0 repeats
       
       @alexshendi that can help a lot more, thanks brother!
       
 (DIR) Post #9qbFyPs2mVbGrzkfwG by alexshendi@mastodon.technology
       2020-01-02T19:05:02Z
       
       0 likes, 1 repeats
       
       @nitoxI think when using the GNU coreutils you can also say:tail -n +23c <file> # character counttail -n +23b <file> # byte counttail -n +23k <file> # kilobyte counttail -n +23m <file> # megabyte countIIRC.
       
 (DIR) Post #9qbHS8XRt1F3kyr1tI by phil@elekk.xyz
       2020-01-02T19:21:35Z
       
       0 likes, 0 repeats
       
       @nitox doesn’t less +G logfiledo the trick?
       
 (DIR) Post #9rQ6ZKBJUvmWz10pqi by malte@anticapitalist.party
       2020-01-27T07:49:55Z
       
       0 likes, 0 repeats
       
       @nitox you mean "head" (as opposed to "tail"?)
       
 (DIR) Post #9rQBcUC1EQzefkfYZ6 by nitox@fosstodon.org
       2020-01-27T08:46:32Z
       
       0 likes, 0 repeats
       
       @malte not exactly, i meant a way to truncate a log fail leaving the last n MB behind