Category "bash"

How to send prompt input to std::process::Command in rust?

I'm writing a cli tool for automate the archlinux installation, that is based on toml config files... Currently i have this problem... Once the base system is i

How to make a pipe conditional within the same line

textfolding="ON" echo "some text blah balh test foo" if [[ "$textfolding" == "ON" ]]; then | fold -s -w "$fold_width" | sed -e "s|^|\t|g"; fi The above code w

How to create and assign a variable name with special character in bash

Sorry if this question is repeated. how can I create a variable a.b and assign a value to it. ---------- root@IN2268980W3:# a=1 root@IN2268980W3:# a.b=1 a.b=1:

Extract tar achives into separate folders

I have a folder containing many tar archives archive1.tar archive2.tar ... I'd like to write a bash script which extracts their innard files to separate folders

How to write a bash command to open up a kafka producer and immediately follow with topic to create?

What's the best way to run the following sequence of commands kafka-console-producer --topic discounts --broker-list localhost:9092 --property parse.key=true --

How to create an alias composed of many commands?

Commands are: git checkout master git remote add upstream [email protected]:minio/console.git git fetch upstream git checkout master git rebase upstream/master Wh

Mutual Exclusion bug subtracting dates

I am trying to run bash code that errors when doing what I think is subtracting minutes from a date. There is an error that has to do with mutual exclusion that

"sleep 5" doesn't delay script for five seconds [closed]

When I use the sleep command and execute the script the sleep doesn't work. The code just gets executed without stopping for the expected 5 se

Splitting a file based on number of records and file size

I have a file which contains 100 records... Each record has different size, like some are 1 KB while some are 1 MB. I want to split the file based upon number o

How to iterate in a range determined by TWO variables?

I have a code: echo "the range's starting number:" read -r a #it was 10 echo "the range's ending number:" read -r b #it was 20 for (( c=$a; c<=$b; c++ )) do

diff 2 files and print only difference bash in Jenkins job

I try to diff to 2 file in bash in Jenkins job If i do this in minigw (eg gitbash) all working just fine But if run same command in Jenkins i got all from files

Detecting negative numbers without interfering with invalid options (starting with -)

I have a bash function that validates numeric values (positive and negative, including integers, floats and in scientific notation). Using a argument parsing lo

Git alias to open the git installation folder

I want to create a git alias git dir, which when used should open the git installation folder via Windows Explorer, how to implement such an alias?

bash: No such file or directory when file is clearly present

I have a shell script located at "/home/pi/scripts/take-snapshot.sh" but when ever I try to execute it I get a error that the file is not present. the following

AWS CLI - Create script to add my IP to security group

I'm trying to create a script to add my IP adress to AWS VPC security groups somthing like > aws ec2 modify-security-group-rules --group-id GROUPID\ > --

Parallel subshells doing work and report status

I am trying to do work in all subfolders in parallel and describe a status per folder once it is done in bash. suppose I have a work function which can return a

bash oneliner search for files and dump name and content into new file

as title says I need to write a bash oneliner that finds all txt files and, for each, writes name and content into another file. So far I wrote: find . -name "*

Bash script: read 30000 records from file and run multiple process in parallel

txt with more than 30000 records. All records are one for line and is an IP like this: 192.168.0.1 192.168.0.2 192.168.0.3 192.168.0.4 192.168.0.5 192.168.0.6 1

Sed: specific exact two match

I have this line in a file. The blanks between the words can be tabs or spaces #define FN_AUTO_FN_FNSECTOR Function(2) /* FN_ comment*/ and I wanted outp

In bash, replace each character of a string with a fixed character ("blank out" a string)

MWE: caption() { echo "$@" echo "$@" | sed 's/./-/g' # -> SC2001 } caption "$@" I'd like to use parameter expansion in order to get rid of the she