How To Delete All Words After X Characters

I read this post: sed delete remaining characters in line except first 5 which helps me to delete all characters after x. However, I'm having a hard time finding how to delete all words after x characters. I started with this code: echo "StackOverf...
more »

2017-10-14 18:10 (5) Answers

Open multiple screens for a list of commands

I have a file in which each line contains a shell script as shown below sh arg1 arg2 sh arg1 sh arg1 arg2 arg3 I want each command to be executed in a separate screen, Is there an easy way to do this rather than creating scree...
more »

2017-10-14 17:10 (1) Answers

STDOUT of nested commands in Bash

Quite new to bash - I'm trying to store the output of my /usr/bin/time command into the TIME_INFO variable, which works with the below setup... however I would also like to be able to store the output of some of the other nested commands (such as /us...
more »

2017-10-14 17:10 (1) Answers

Concurrency race between child and parent signals

I found this problem in a past exam from CMU and I can't get how the outputs were possible. basically, the idea behind it that there is a parent process that blocks a user-defined signal, then the parent forks a child. and based on which process tha...
more »

2017-10-14 14:10 (1) Answers

Can't create RFCOMM TTY: Address already in use

I listen for a Bluetooth connection in my server doing: rfcomm listen rfcomm1 1 Then I connect with my Bluetooth client and this message appears: Connection from XX:XX:XX:XX:XX:XX to /dev/rfcomm1 Press CTRL-C for hangup This means that everythi...
more »

2017-10-13 20:10 (1) Answers

How to temporarily suppress output from printf?

In a console application I am calling a library function that outputs some messages (probably using printf) that I am not interested in: void libFoo() { // does some stuff printf("boring message"); // does some more stuff } I tried sup...
more »

2017-10-13 13:10 (1) Answers

Grep resource usage

I have been tasked with writing a shell script to grep through hundreds of log files in many directories on Linux and Solaris servers. Some of the logs are compressed in many formats and some are a few GB in size. I am worried about grep using a lot ...
more »

2017-10-12 20:10 (1) Answers

How to write a Linux command in a Dockerfile

I have a linux shell command, that need to be written in a Dockerfile. for ((i=10001; i<10101; ++i)); do pwgen -n -s -B -c 10 | sed "s/^/$i /"; done > user.tx_ ; /bin/cp -f user.tx_ user.txt ; Anybody can help me ? Thank you very much. ...
more »

2017-10-12 09:10 (2) Answers

Using sed and awk to edit lines in a file

I have a file of a few host names separated by spaces then a location. host1 C1U5 host2 C11U55 host15 C5U10 I have to edit the file of hosts. I have written the sed/awk lines to remove characters but my sed lines just returns the full line. I...
more »

2017-10-11 22:10 (5) Answers

Bash JSON string into variable

my idea is to put json string into variable JSON, i have a command whom takes a console login to user in AWS IAM, the comand is : aws iam create-login-profile --cli-input-json file://create-login-profile.json in create-login-profile.json is the jso...
more »

2017-10-11 14:10 (1) Answers

Linux Buddy page frames allocation and freeing

While reading and understanding linux kernel using the guide- I have something I'm trying to understand in the Buddy system for page allocaion and freeing. The techni...
more »

2017-10-11 12:10 (1) Answers

Remove Words Shorter Than 4 Characters Using Linux

I have read the following and tried to rework the command logic for what I want. But, I just haven't been able to get it right. Delete the word whose length is less than 2 in bash Tried: echo $example | sed -e 's/ [a-zA-Z0-9]\{4\} / /g' Remove all...
more »

2017-10-10 21:10 (3) Answers

Search in CSV and count the entries

I have a csv file which imaging my inventory sort and uniq: |Nivcomp Nivelliergerät |Bosch Rotationslaser GRL 300 HV |Renault T440 |Renault Master |Spritzer Silo ... The second CSV file contains the complete inventory. I would like to find and co...
more »

2017-10-10 21:10 (0) Answers

Bash - Rename file that have " in it

Ok I have a function that will have as parameter a string and it will output a new string that doesn't have any spaces, ', " function rename_file() { local string_to_change=$1 local length=${#string_to_change} local i=0 local new_string=" " loc...
more »

2017-10-10 18:10 (1) Answers

Run ls command inside ssh

I have a script something like below sshpass -p "pwd" ssh -tt user@host << EOF cd /directory file=$(ls -1t| head -1) exit EOF cd /directory is changing the directory successfully inside shell. But ls gives the result which is outside...
more »

2017-10-10 12:10 (1) Answers