Skip to content

Tag: linux

Print min and max with awk

Why wont this awk script work, where I want to print the min and max of an input by just reading the data once. I would also like to initialize the min and max variable with the first value of the data. Say I have a file I am using awk to print the min and max with: But I

Can’t redirect printf to pipe

I want to redirect the output of printf to a pipe, but for some reason it doesn’t seem to work. What does work is using write instead. This is my program if I replace write with the commented line, my program just blocks Answer Either add a new line character (n) to your output or use fflush() as Barmar…

AMQP transfer frame refused

I am currently trying to develop my driver to an ActiveMQ via AMQP 1.0 I could successfully open, begin a session, attach links to this session but my first transfer frame is refused with “error decoding” although wireshark sees it as valid frame as shown in screenshot wireshark view of transfer f…

Cleanup output from GDB memory dump

We lost a configuration file which we were able to recover some of the data with a gdb memory dump but many important parts of the file are buried in memory noise. Is there a way to cleanup the dump files? Example output Answer The strings command was able to remove the garbage from the file.

Are inotify event reads guaranteed not to be split across buffers?

All of the code examples for inotify do something like this: So presumably this allows for a single read() call to return up to 1024 events. What if there are actually more events than that in the queue? Will inotify guarantee to return a whole number of events, even if that means a short read? Or will inotif…

Setting environment variable to command in a script

I made a bash script. It reads a file contains a list of commands and runs each of them. A list of commands is like below. Each line has a environment variable before command to set same name but different value to commands. A script is like below. I expect: run command1 with ENV_NUMBER=1 run command2 with EN…