Skip to content

Tag: linux

Add up a column of numbers at the Unix shell

Given a list of files in files.txt, I can get a list of their sizes like this: which produces something like this: How can I get the total of all those numbers? Answer is the shortest one I’ve found (from the UNIX Command Line blog). Edit: added the – argument for portability, thanks @Dogbert and …

struct ip_mreq disappears when compiling with -std=c99

On some of our linux boxes compiling with gcc -std=c99 makes struct ip_mreq disappear (included from netinet/in.h) Is there some other interface we are supposed to use ? Answer Try –std=gnu99. The default for GCC is ‘–std=gnu89’ which means C89 with GNU extensions. By selecting ‘…

Running Excel Macros Automatically under Linux

Part of the software I work on uses an Excel sheet to store the user error messages & their translations. We run a macro which generates a set of internationalized text files & matching header files that are then copied into our version control system (the spreadsheet is also in Version Control) and u…

Surprise! the shell suggests command line switches

I noticed that the bash shell can suggest command line switches for your command. Just type your command, a dash (-) and type tab. The shell will show you available switches. For example, try: and press tab – Surprise! The question is: How do I interface with this feature. I.e., if I write a program tha…

Pipe to/from the clipboard in a Bash script

Is it possible to pipe to/from the clipboard in Bash? Whether it is piping to/from a device handle or using an auxiliary application, I can’t find anything. For example, if /dev/clip was a device linking to the clipboard we could do: Answer 2018 answer Use clipboard-cli. It works with macOS, Windows, Li…

What killed my process and why?

My application runs as a background process on Linux. It is currently started at the command line in a Terminal window. Recently a user was executing the application for a while and it died mysteriously. The text: Killed was on the terminal. This happened two times. I asked if someone at a different Terminal …

Static link of shared library function in gcc

How can I link a shared library function statically in gcc? Answer Refer to: http://www.linuxquestions.org/questions/linux-newbie-8/forcing-static-linking-of-shared-libraries-696714/ You need the static version of the library to link it. A shared library is actually an executable in a special format with entr…