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 “Important: FILE1 and FILE2 must
Redirecting packets to user space TCP stack without modifying application
I’m using a user space TCP stack based on the Linux stack running under Linux. Unfortunately it requires applications to specifically call its own modified versions of the normal sockets API functions and then just grabs incoming packets it receives in response using libpcap. Now my question is whether there is any way to redirect packets from an application to
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 @Owen.
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 ‘–std=c99’ you are enabling C99, but disabling the GNU extensions. ‘–std=gnu99’ will select both C99
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 used as part of our build. I’d
How do you link to a specific version of a shared library in GCC
I’m compiling some code which uses libcurl on a Debian Linux system. My dev machine is running Debian 5 but I want the binary to be usable on older Debian 4 systems too. I find that if I specify -lcurl it will link to libcurl.so.4 but Debian 4 systems only have libcurl.so.3 Is there some way I can tell GCC
how do I find out what program’s on the other end of a local socket?
A process on my Linux system, strace tells me, is talking on a socket which has file descriptor 10. lsof tells me that this is a unix socket with inode 11085, and netstat further tells me that inode 11085 a stream socket, and that it’s connected. Given that this process doesn’t have any other threads, there must therefore be another
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 that is to be run
Stripping single and double quotes in a string using bash / standard Linux commands only
I’m looking for something that will translate a string as follows, using only bash / standard Linux commands: Single-quotes surrounding a string should be removed Double-quotes surrounding a string should be removed Unquoted strings should remain the same Strings with unmatched surrounding quotes should remain the same Single-quotes that don’t surround the string should remain Double-quotes that don’t surround the
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, Linux, OpenBSD, FreeBSD, and Android without any real issues.