Skip to content

Tag: file

Unable to lock file linux

I’m trying to lock a file and obviously there is something I’m missing, because eventhough it seems it’s locked I can still access and edit it using vim editor. Locking file: Checking using lslocks: But still able to access it and edit using different terminal (different process I believe). …

How do I get the filename of an open std::fs::File in Rust?

I have an open std::fs::File, and I want to get it’s filename, e.g. as a PathBuf. How do I do that? The simple solution would be to just save the path used in the call to File::open. Unfortunately, this does not work for me. I am trying to write a program that reads log files, and the program that write…

Piping to File Utility

I am being sent the bytes of thousands files over an interface, and my app must maintain statistics regarding the counts of various files types which it observes (text, HTML, binary, compressed, etc.). I have been using the subprocess module to run the file utility. However, as the scale has increased, I am h…

Unix -Delete even bytes from a file

I want to find and delete all even bytes from a file given in command line. Is there any command for this situation? Answer I think this does what you want. It dumps the file as continuous plain hex, then reads two bytes, saving them for later and then two more bytes. Then it outputs the bytes it saved and