Skip to content

Group the consecutive numbers in shell

In shell, how to group the numbers in $foo as 1-3,6-8,11,13-17 Answer As an alternative, you can use this awk command: Now run it as: Here is an one-liner for doing the same: In this awk command we keep 2 variables: p for storing previous line’s number s for storing start of the range that need to be pr…

Capture a set of numbers in sed

I have the following string I am trying to capture only v2010.0_1.3 using and I get the following result v2010.0_1.3 Tue Jun 6 14:38:31 PDT. It looks like sed is not stopping the first occurrence of the space, but at the last one. How can I capture only until the first occurence? Answer Using sed sed’s …

socket recv function not returning updated value

Trying to create socket application using c (Linux) to constantly fetch data from a server For this I have created a loop and inside it the routine connects , send a command, receive some data and close the socket. It works fine for the first interaction but looks like the recv function failing to update the …

DKIM key not valid – Bad RSA signature

I have setup DKIM on a Ubuntu 14.04 machine using opendkim and postfix. I generated the RSA keypair and updated the TXT record. When testing the settings at any DKIM tester like www.mail-tester.com or www.dkimvalidator.com, I get errors like “result = fail, bad RSA signature”. Here is an example m…

Signal Handling C programming on ubuntu

While I sending kill -9 command to a program on ubuntu , I want to close other running processes before the program closes.I am trying this with c programming . Could it be something like this? How can I say program if you get KILL command you should do something? Answer Per the POSIX standard <signal.h&gt…

Python paramiko executing sudo

I am using paramiko put method to send file from local to remote server. However, I am having problem executing sudo su – user command to view the file from remote. I also tried changing the permission from local but the file permission stays intact when transferred. Is there a way to execute sudo su &#…

Does an argument after a redirection do anything?

Is any argument after a redirection ignored, or does it have any unintended consequences? I was surprised to find that a typo I made in my bash script made absolutely no difference because it was specified after a redirect. E.g. I expected it to complain about something like this But it doesn’t throw an…