Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [bash]

For questions about scripts written for the Bash command shell. For shell scripts with errors, please check them with the shellcheck program (or in the web shellcheck server at https://shellcheck.net) before posting here. Questions about interactive use of Bash are more likely to be on-topic on ...

0
votes
0answers
8 views

change color setting of file being displayed with UNIX less command

i have a log file with ^A as a delimiter. i want to change the background color of this delimiter to make things easier to see. i understand changing the background color is already answered here: ...
1
vote
1answer
7 views

Bash: How do I show the name of a specific java -jar in Top command?

Note: this is not a java question. I'm asking about the Top Command in bash. Often I am running several programs written in java at the same time. For example; `java -jar [program] [options]` I ...
0
votes
3answers
1k views

Determine if file location is an alias in bash scripting

Symlinks are different than aliases, although they seem to serve the same purpose (more or less/I think). I need to be able to tell if a file is an alias, and if [ -h /path/to/file ] doesn't work. ...
0
votes
1answer
43 views

Wait until a condition is met in bash script

until [ $(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text) = *"InProgress"* ]; do echo "Automation is running......
2
votes
2answers
80 views

How could I install Torch on Google Colab if it does not exist the file ~/.bashrc?

I want to install Torch (http://torch.ch/docs/getting-started.html#_) on Google Colab. However, to install Torch, we need to run the following command at the final step source ~/.bashrc To run this ...
0
votes
1answer
19 views

How not to resolve all users with tilde and tab completion in bash

To go in some subfolder of my home folder I type cd ~/sub[tab]. This is completed to cd ~/subfolder. Everything is fine. If I accidently forget the slash and type cd ~sub[tab] all users are being ...
6
votes
7answers
3k views

Sequences expansion and variable in bash [duplicate]

I am having a problem with builtin sequences (ie: not using seq) in Bash when the seq number is a variable. For example, this works and print me 1 2 3: for i in {1..3};do echo $i;done but this : ...
1274
votes
39answers
582k views

How to count all the lines of code in a directory recursively?

We've got a PHP application and want to count all the lines of code under a specific directory and its subdirectories. We don't need to ignore comments, as we're just trying to get a rough idea. wc ...
0
votes
1answer
16 views

How to run elasticsearch via docker compose (docker stack) and install delete-by-query plugin

Problem Statement I have a docker-compose.yml file (v3) that looks like the following: version: '3' services: elastic: restart: always image: elasticsearch:2.3.1 command:...
0
votes
0answers
9 views

GtkDialog loading multipy images in a window

I'm busing building a app store in gtkdialog using bash. I'm forced to use bash for other reasons being. Although this is not the problem. For some reason due to the lack of documentation I can't find ...
-2
votes
4answers
66 views

Separate multiple subdomains into all possible subdomain combinations using bash and awk

I'm trying to separate multiple subdomains into all possible subdomain combinations using bash. For example if subdomains.txt has: www.ir.example.com www.it.api4.qa.example.com www.api.example2.com ...
0
votes
2answers
26 views

How to get Multiple inputs with single variable?

I was writing a Multiboot script, but stucked in a little mess, I wrote a function like this, read -p "Drag & drop the iso's on Terminal : " isofile1 Now I applied condition that when just ...
0
votes
1answer
27 views

Using map functionality in shell script

I have below shellscript MYMAP12=$(java -jar hello-0.0.1-SNAPSHOT.jar) echo "===" echo ${MYMAP12} The output of java -jar hello-0.0.1-SNAPSHOT.jar will be map {one=one, two=two, three=three} how to ...
79
votes
10answers
122k views

source command not found in sh shell

I have a script that uses sh shell. I get an error in the line that uses the source command. It seems source is not included in my sh shell. If I explicitly try to run source from shell I get: sh: ...
-2
votes
1answer
41 views

Executing bash commands from flask application

Application Details: Ubuntu 16.04 + flask + nginx + uwsgi I am trying to execute a bash command from flask application. @app.route('/hello', methods=('GET', 'POST')) def hello(): os.system('...
157
votes
4answers
171k views

Bash script processing limited number of commands in parallel

I have a bash script that looks like this: #!/bin/bash wget LINK1 >/dev/null 2>&1 wget LINK2 >/dev/null 2>&1 wget LINK3 >/dev/null 2>&1 wget LINK4 >/dev/null 2>&...
0
votes
1answer
14 views

MYSQL SHELL - SQL MODE from SHELL SCRIPT

I am writing a shell script to run a sql select query using mysqlsh. So I had some issues and I found that I need to use "\sql" to change it from mysql-js> to mysql-sql> I need to run /sql before ...
1
vote
3answers
3k views

How to write binary data in bash

Let us say there is a variable in bash script with value "001" how can i write this binary data into a file as bits (as "001" not "1") echo writes it as string but i want to write in bits.
0
votes
1answer
15 views

Checking out a Github PR and then pulling updates?

I wrote a little bash script to check out PRs on the fly with: co URL co() { set $1 git fetch upstream git checkout pr/${1##*/} } Once I am checked out on the branch, I'm wondering the ...
0
votes
1answer
38 views

coreutils timeout in a bash script not transparent for the application

I have an issue with executing application via /usr/bin/timeout in a bash script. In this specific case this is a simple python fabric script (fabric version 1.14) In order to install this version of ...
0
votes
1answer
24 views

My code is giving that error: ./greeting2.sh: line 11: syntax error: unexpected end of file [duplicate]

Guys I'm a begginer in learning bash scripting and I don't know what error is that, I'm using the latest LTS of Ubuntu and it's giving that error: ./greeting2.sh: line 11: syntax error: unexpected end ...
2
votes
1answer
27 views

Automatically enabling bash completion on Fedora 28

I have a Fedora 28 installation on which I have installed the bash bash-completion package. I have run the following: source /etc/profile.d/bash_completion.sh And bash completion works as expected. ...
0
votes
1answer
25 views

output returns nothing when running script

When I run this script I get nothing returned. Any suggestions? Here is the code. securityTlsVersion() { local file="/usr/lib/firefox/mozilla.cfg" local config=`more $file|grep security....
1
vote
0answers
18 views

Use Variable from Variable Group in bash script on VSTS

I have linked a variable group to my build pipeline. The variable group has a variable in it. I am trying to use the variable in a bash script in my pipeline. This document describes how to reference ...
7
votes
2answers
7k views

How can I scp a file and run an ssh command asking for password only once?

Here's the context of the question: In order for me to be able to print documents at work, I have to copy the file over to a different computer and then print from that computer. (Don't ask. It's ...
0
votes
1answer
20 views

dynamic string serach in shell script

I have a string in shell script which is list="apr/2018-06-24 17_10_39/2018-06-24 17_10_39.html apr/2018-06-24 17_10_39/access_log.zip apr/2018-06-25 17_12_48/2018-06-25 17_12_48.html apr/2018-...
0
votes
0answers
24 views

How to decrypt a read-only encrypted chromebook wifi password on Chrome os (linux)

I would like to decrypt a wifi password that my chromebook has been registered to. The encrypted code is: CbD4Fb4o=:7_C?:4oE:_?>b For some reason, when I run the linux/chrome shell command to decrypt ...
1
vote
2answers
20 views

What does . /opt/pat/staging/config/VARIABLES>>/dev/null do? [duplicate]

What does this command mean in a shell script? What is the functionality of writing this command in the shell script?? . /opt/pat/staging/config/VARIABLES>>/dev/null
1
vote
5answers
5k views

Bash based regex domain name validation

I want to create a script that will add new domains to our DNS Servers. I found that Fully qualified domain name validation REGEX. However, when I use it with sed, it is not working as I would expect:...
1
vote
1answer
27 views

Bash: given a list of arguments separated by newline, how to pass all of them to another process?

A little backstory, because maybe my approach is fundamentally wrong: Currently I'm trying to make a pre-commit script that checks what files where changed and passes them to a linter. Here's what I ...
2
votes
2answers
2k views

Bash copy verbose update in Solaris

I'm writing some small bash scripts for copiyng certain files/directories in GNU/Linux and Solaris. Everything is OK in Linux, but cp command hasn't the same options in Linux and Solaris. Copy ...
0
votes
2answers
52 views

Capture sub-string at different positions from command's output

I have a requirement, where I have to capture a string from a command's output and store it for further processing. Problem is that the command's output may change sometimes and hence this leads to ...
0
votes
1answer
33 views

extract specific lines in text file using bash

i am running this command: grep "folder1/folder2/folder3/.\*/results/.*.vcf.gz" some_file.txt |grep ".vcf.gz$" > vcffiles.txt and my output in the vcffiles.txt file is this : folder1/...
-1
votes
2answers
26 views

need help understanding bash syntax [on hold]

I am trying to understand bash syntax a bit better, and I need some help with a while loop: The following script works: #!/bin/bash # counter=2 mystring=testdir while [ $counter -le 5 ]; do echo ...
0
votes
0answers
28 views

Pass all environment variables to sudo'ed script

I have one shell script that calls another using sudo, e.g: test1.sh: #! /bin/sh echo "In test1" UVAR=bar echo "UVAR=${UVAR}" sudo ./test2.sh echo "In test1 - after call to test2" echo "UVAR=${UVAR}" ...
183
votes
14answers
102k views

Delete all local git branches

I follow a development process where I create a new local branch for every new feature or story card. When finished I merge the branch into master and then push. What tends to happen over time due ...
0
votes
1answer
48 views

How to work around open files limit when demuxing files?

I frequently have large text files (10-100GB decompressed) to demultiplex based on barcodes in each line, where in practice the number of resulting individual files (unique barcodes) is between 1K and ...
0
votes
2answers
33 views

How to make a script that goes through all the .m and .h files and replaces this line of code [on hold]

I wish to make a script that recursively goes through every file with a .m or .h extension, then looks for this pattern: #import <React/ThisCanBeAnyText.h> and replaces it with this: #if ...
0
votes
0answers
12 views

Getting all nodes from a xml file using XMLStarlet

I'm trying to get all displays linked with all hardwares in a XML file. I tried to created a XMLStarlet with all these informations : DataFund=$(xmlstarlet sel -T -t -m "hardwares/hardware" -n -v "...
0
votes
0answers
40 views

Curl - Invalid params null

I tried to make a script to post a request every time travis-ci build is finished. I got this error: Invalid params null, 1668, https://github.com/HyperiumClient/Hyperium/releases/download/1668./...
-1
votes
0answers
10 views

Creating own video server with ffserver/ffmpeg streaming RTSP

I have created app that plays video when url is provided. It can recieve video via RTSP (already tried to play famous big bunny), but now I want to debug it with my own server. Currently I have ...
1
vote
1answer
29 views

Making associative array based on another associative array

I made an associative array as follows. To give a few details, the keys refer to specific files because I will be using this array in the context of a larger script (where the directory containing the ...
0
votes
0answers
28 views

Mac Command to find a first occurrence of string and replace it ?

{ "service " : "namespace" "name" : "test " "name" : "abc" } I need to replace the first occurrence of name as "name" : "test 12-12-34 12:09" and the value "12-12-34 12:09" is in some another ...
1
vote
1answer
23 views

Pass env var in makefile as optional

I have a command in a makefile that executes a bash script: test: ./script.sh The script has getopts implemented so it can be called like this: ./script.sh -n 10 what can in bash be accomplished ...
0
votes
4answers
26 views

sed replace substring only if expression exist

in a bash script, I am trying to remove the directory name in filenames : documents/file.txt direc/file5.txt file2.txt file3.txt so I try to first see if there is a "/" and if yes delete everything ...
0
votes
0answers
36 views

why is this reverse shell echoing every command?

I create a local reverse shell following this post, the shell keeps echoing my command(without prompt) right after hitting Enter. victim:~# ls ls <- echo realfile1 realfile2 but if I change the ...
0
votes
0answers
24 views

how to fix this error in bashrc

enter image description here I added a list of alias to .bashrc and when I use . ~/.bashrc to refresh the list I get this error. list of alias I added: alias a="sudo apt-get install" alias c='...
1
vote
2answers
31 views

How to define a value in bash shell for?

I have a problem while using sh linshi.sh. The content of linshi.sh is: for i in `cat host-user.txt` do host = awk '{print $1}' $i user = awk '{print $2}' $i echo $host echo $user ...
1
vote
2answers
659 views

-bash: rabbitmq-server: command not found

Trying to start my rabbitmq server, but I get this error. I've followed all of the instructions on how to install it. The rabbitmq-server file lives inside /usr/local/sbin. So I change directory to ...
0
votes
1answer
19 views

Listing of files in directory in shell script

I am having list of xml files in a folder like - data0.xml, data1.xml, data2.xml, ...data99.xml I have to read the contents of these files for further processing. Currently I am using for loop like ...