Category "bash"

How to combine multiple commands output in the one varialble in shell script?

I'm using the following script to get the data of one of the variables from the database file #!/bin/bash sqlite3 pdu.db <<'END_SQL' .timeout 2000 SELECT

BASH : control exits CASE logic after entering any condition - Unable to understand the reason

I have an input file, which has below data : driver2:y driver5:y driver3:n driver1:y driver4:y The requirement is, for each driver if the value is "y" then the

Do you need to include export for environment variables in bash profile / zshrc?

Do you need to include export for environment variables in Bash profile / zshrc? I'm using Z shell (Zsh) for my terminal and in my .zshrc file I have the two li

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 "*