Skip to content

Padding Empty Field in Unix Join Operation

I have two files where I want to perform union operation based on 1st column: file1.txt file2.txt The result I hope to get is like this: where the empty fields of column 1 is padded with “-“. But why this join command doesn’t work as I expected? What’s the right way to do it? Answer &#…

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…