Questions tagged [bash]

This tag is for questions about scripts written for the Bash command shell. For shell scripts with syntax or other errors, please check them at https://shellcheck.net before posting them here. Questions about the interactive use of Bash are more likely to be on-topic on Unix & Linux Stack Exchange or Super User than on Stack Overflow.

bash
Filter by
Sorted by
Tagged with
0 votes
0 answers
32 views

Why can I skip the blank on command line arguments (.e.g, script -ARGNAMEargvalue)?

I sometimes see command line calls to programs/scripts with optional arguments, where the whitespace between the argument and the value is skipped, e.g.,: scriptname -ARGNAMEargvalue I find it tough ...
Christopher Graf's user avatar
0 votes
1 answer
516 views

Start forever using bash if it is not executing

I have a socket application, which is created in node js. I was using forever to run this application. Due to some reason, forever is stopping automatically. I have created a script to check the port ...
Shijin TR's user avatar
  • 7,656
1 vote
2 answers
2k views

How to limit the number of results from find?

I would like to do something like: find ./ -name "*.jpg" -nbresult 50 -exec cp {} /50randomsjpgfrommyharddrive I can use head and xargs, but with -print0, head doesn't work any more.
Fractale's user avatar
  • 1,522
0 votes
1 answer
231 views

How do you iterate over environment variables that are sequentially numbers?

I have an application that takes from 1 to 20 variables. The names of each of the variables are identical EXCEPT they end with a sequential number. From _1 to _20. For example: Value_1, Value_2, ...
KSS's user avatar
  • 971
0 votes
2 answers
98 views

How to apply changes from specific commits in specific order

Cn - parent commit. Cn+1(green) - local commit. Cn+1(yellow) - another commit in same branch but already pushed to remote, but have same parent as local commit. Result: I need to save all changes ...
Nitro Boy's user avatar
1 vote
0 answers
867 views

Problems with AWS credentials when renewing Let's Encrypt certificates with certbot

I have 4 servers with Let's Encrypt HTTPS certificates which should renew with certbot. They were created with user ubuntu with the flags --dns-route53, --dns-digitalocean and --dns-digitalocean-...
Uri's user avatar
  • 3,072
1 vote
3 answers
56 views

I need to create a list of folder directories that do not contain a file with a specific name using bash

Problem: I am running a large number of simulations (~14000) and each simulation if executed correctly is supposed to generate 10 different files and 1 folder containing 3 files. Sometimes if the ...
karts11's user avatar
  • 11
2 votes
1 answer
50 views

Increase encryption level to 128-bit for password pdf protection with CAM::PDF

I have been using CAM::PDF perl module for password protection of pdf documents, The default encryption level is 40-bit. This is not very strong. Is it possible to increase this to at least 128-bit? I ...
Raj's user avatar
  • 31
0 votes
1 answer
424 views

Why does invoking R script using RScript works but not with R binary?

Is there something about the way she-bang works that I am missing? # why does this not work? § ./sample.r ./sample.r: line 3: 1: command not found § ll sample.r -rwxr-xr-x 1 raghu.dodda staff 39 ...
sudocracy's user avatar
  • 1,718
0 votes
1 answer
2k views

syntax error unexpected token bash scripting

I am getting a few of these errors in my bash script. I am new to the language. Any pointers? #!/bin/bash echo "Calculating the value V for all given values" inflation=(0 0.03 0.05) tax_rate=(0 0.28 ...
Isha Bhatt's user avatar
-1 votes
2 answers
121 views

Mac Terminal to run a bash script that starts a swift program & restarts every hour

I am looking for some support on creating some way of running a swift command in terminal to run a program and then stop it after 1 hour then restart. Example of manual process: Open Termain. cd ...
Ben Doyle's user avatar
1 vote
1 answer
605 views

Find file created at a specific time of the day

i need to use the find command in bash to search for files created on a specific hour of the day, for example files created between 12:00 and 12:59. is there any way to do that ? That's the code I'm ...
Vasal's user avatar
  • 35
0 votes
0 answers
212 views

Regex error occurs when trying to run Workflow Template on my local machine for Google Cloud Platform

I created a workflow template that looks like this: template_name='reddit_etl' cluster_name='spark-job-reddit' yesterday_date=$(date -d '-1 day' +'%Y-%m-%d') bucket=gs://r-etl gcloud beta dataproc ...
clark_s's user avatar
  • 41
0 votes
1 answer
84 views

Bash script pipe barrier [closed]

My current script looks like this: #!/bin/bash trap flush_buffer SIGUSR1 flush_buffer() { echo "flushing buffer" >&2 [ -n "$buffer" ] && echo -e "$buffer" buffer="" } ...
Julian's user avatar
  • 5
0 votes
0 answers
627 views

Running docker as sibling

I am trying to run a container (hello-world) as a sibling from another container (dev). But, container script is not able to access "Docker". I am getting Docker not found error Here is what I ...
user1743514's user avatar
0 votes
1 answer
81 views

Programatically cycle through arguments given to a script or function

I'm trying to cycle through an unknown number of arguments given to a bash script (or function within), to effectively handle the odds ($1, $3, etc.) and evens ($2, $4, etc.) in different ways. I ...
ScottC's user avatar
  • 148
0 votes
2 answers
276 views

Why does echo command interpret variable for base directory?

I would like to find some file types in pictures folder and I have created the following bash-script in /home/user/pictures folder: for i in *.pdf *.sh *.txt; do echo 'all file types with ...
Peter's user avatar
  • 1,280
1 vote
2 answers
1k views

Search and delete links in markdown files

I run from time to time a linkchecker over my site and the external links 404 will be saved to a logfile. Now I try to delete the links automated from the markdown files. I use multilingual websites ...
Silvio's user avatar
  • 123
0 votes
1 answer
580 views

How to iterate sql query result set in bash script

I am trying to write a bash script which will iterate through output of below sql query (we are using oracle database). Depending upon value of module column, we need to pass value of any one of the ...
Ranjeet's user avatar
  • 305
1 vote
2 answers
276 views

Exit script if a service fails [duplicate]

I want to stop the execution of my bash script if a certain service fails to run. systemctl is-active --quiet nginx || (echo "Nginx couldn't be started...exiting" && exit) I do get the Nginx ...
user2650277's user avatar
  • 6,541
1 vote
2 answers
85 views

print lines that don't match array elements

I have an array arr=( 'error one' 'error two' 'error three' ) and a file I want to find errors in a.txt with contents (example). error one error two error three error four error five error six ...
mcg's user avatar
  • 13
0 votes
0 answers
168 views

how to identify the difference between two date time in bash? [duplicate]

I want to identify the working hours between the below two different dates in bash? date1="2020-04-17 20:09:42" date2="2020-04-28 20:40:10" difference= <should be in hours>
Arun Srinivasan's user avatar
7 votes
2 answers
7k views

Run shell script globally in Git bash in Windows

I have a shell script that I want to run globally. It's current directory is ~/directory/script.sh I can run the script only from the directory in which the script is located, however, I'd like to ...
Roy's user avatar
  • 1,812
0 votes
0 answers
43 views

print nth, (n+3)rd, ((n+3)+3)rd,.... lines using awk [duplicate]

1 ADD file ... in / 21.44 MB 2 CMD ["bash"] 0 B 3 ENV DEBIAN_FRONTEND=noninteractive 0 B 4 COPY file:6229791a987783682b536a308b0d287c470ec1bfa0be9b6b3471feab66706874 in /install.sh 925 B 5 /bin/sh -c /...
Kosmos Nagios's user avatar
1 vote
1 answer
1k views

zcat skip streaming first line while reading from a compressed file

I am using the zcat command and streaming a .tar.gz file through a piping operation. I want to skip the first line while zcat reads the file. How is it possible?
Pujan Paudel's user avatar
10 votes
1 answer
421 views

How POSIX compliant is "/path/file/.."?

I wanted to change current directory into shell script into directory, containing specific regular file. I found that following trick works in mksh and busybox sh: path=/path/to/regular/file cd $path/...
KAction's user avatar
  • 595
1 vote
0 answers
30 views

git checkout auto completion when specifying --git-dir or -C arguments

Im not sure it is possible, but im trying to get auto completion for git (add & checkout) in bash (ubuntu 18.04) to work when not in a git version controlled directory. Ive tried using: me@home:~:...
bryan sammon's user avatar
  • 7,281
1 vote
1 answer
64 views

Merge two different files using specific columns after a match and add N/A when no match

File 1 Time C-ID Room Info N_Range ErrorCodes Stability Position Profile Configuration N-East EAST North 10:29:18 13832216 1Tr1Tr1Tr10 VILNARPN ...
Driven's user avatar
  • 159
0 votes
1 answer
37 views

Regex to capture #Facilitator:"Full Name <[email protected]>" tags

Please help with the regex, the language can be any. I'll later translate it to python. I'm trying to build a regex to capture the tag below: #Facilitator:"Full Name <[email protected]>" Full ...
Pabluez's user avatar
  • 2,707
0 votes
0 answers
123 views

bash - count, process, and increment thru multiple "Tasks" in log file

I have log files that are broken down into between 1 and 4 "Tasks". In each "Task" there are sections for "WU Name" and "estimated CPU time remaining". Ultimately, I want to the bash script output to ...
MHJessen's user avatar
1 vote
2 answers
236 views

Attempting to install FSPS raises environment variable error

I am trying to install the python interface of the fsps program. However, when I run sudo python3 setup.py install I get the error: Traceback (most recent call last): File "/mnt/c/Users/Lea/...
user1093541's user avatar
1 vote
4 answers
6k views

combining || and && in bash [duplicate]

When I execute this in the following line in my shell echo this || echo that && echo other The output is: this other Now I don't understand how echo other is executed, because echo that ...
Xenon's user avatar
  • 187
0 votes
0 answers
71 views

Bash: cannot append to local array

The following script works: #!/bin/bash func () { local VAR=( "${VAR[@]}" "$1" ) echo "${VAR[@]}" } func test Output: test After changing the way how the array is appended, the script starts ...
Alex Zhu's user avatar
0 votes
0 answers
19 views

How to loop over different subdirectories and fetch different files using bash [duplicate]

I'm trying to loop over different subdirectories and fetch the files.but getting "no such file found exception" For example : structure is like tmp/app1/app1a/some.yml and tmp/app1/app2a/some.txt tmp/...
kirru's user avatar
  • 9
0 votes
0 answers
220 views

Error: Perhaps you are running on a JRE rather than a JDK? (Ubuntu Bash Shell)

So, I'm trying to start building a project using the jhipster generator with React framework on the front end and Spring Boot on the back end. I am on a Windows computer but am using the Ubuntu Bash ...
mtibo's user avatar
  • 61
-2 votes
2 answers
2k views

bash script (or something else) to automate docker tag docker push

Looking for help to write a bash script to automate my docker workflow, or open to suggestions what to do instead Current workflow is: 1. me$ docker images REPOSITORY ...
emraldinho's user avatar
-1 votes
4 answers
233 views

combine 2 awk or sed statements into one and save the existing file

My objective is to only modify the line that begins with data, which there is only one of. In this line, I am replacing the 51-80 characters and the 97-126 characters. I would rather have a one liner ...
Jason Smith's user avatar
1 vote
1 answer
289 views

Restarting a shell script with a signal

I have a script that runs and outputs to my panel. What I'm trying to do is to restart the script from another script by sending a siganl to it. Script 1 (panel_script): #!/bin/sh trap "exec ...
S9oXavyF's user avatar
  • 105
3 votes
1 answer
5k views

What does @<(cat <<- EOF do in Bash?

I've stumbled upon some weird heredoc usage in a Bash script. A simplified example goes like this: do_stuff() { notify @<(cat <<- EOF { "key": "value", <more JSON ...
planetp's user avatar
  • 15.2k
1 vote
1 answer
28 views

how can find the latest subdir

I have the following structure /storage/archive/mp3/A/1dir /storage/archive/mp3/A/2dir /storage/archive/mp3/A/3dir/a3dir /storage/archive/mp3/A/4dir/a4dir/a44dir I always want to output the last ...
kuck's user avatar
  • 97
0 votes
1 answer
139 views

GnuPlot with timestamp start to timestamp end position as x for job scheduing graph

I wanted to try to automate the plot of some jobs scheduled on GPU nodes of a grid that is executing interdependent analysis. Without a profound experience with GnuPlot, I managed to start from ...
FilTius's user avatar
  • 13
0 votes
1 answer
873 views

How to get total memory used in MB by nodejs process with bash on centos

Somehow with PM2 imonit, it can display CPU and Memory used by nodeJS process. How can I get the same value (MegaBytes) in total with bash scripting on centos? This what I've : admin@cent7a ~/w/s/...
ddk's user avatar
  • 31
0 votes
0 answers
22 views

bash: command works when inputted manually but not on script [duplicate]

I have a simple bash command, which does some stuff and at some point tried to delete everything except a few things. When running inside a script, it fails. But when I try to run it again, it works. ...
blasrodri's user avatar
  • 448
-1 votes
1 answer
83 views

how to count files only in specific subdirectories located deeply in the hierarchy?

I need to count all sessions files sess_* located in TMP directories (Debian machine) and know path to each TMP with the count for each one. All parent direcotries are in /somepath/to/clientsDirs. ...
Radek's user avatar
  • 3
0 votes
1 answer
94 views

Update tag value according to attribute name xmlstarlet

I have a file : <?xml version="1.0"?> <openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude"> <theme> <name>YYYY</name> &...
user avatar
4 votes
1 answer
466 views

nodejs failed but bash doesn't stop even I have set -e

I run a script in nodejs that trigger by bash that run by Jenkins pipeline. The problem is the pipeline doesn't stop when the error happens. it should not run "echo git add ." I add set -e - but ...
Jon Sud's user avatar
  • 11.1k
0 votes
2 answers
369 views

BASH: How to make a script that update every X seconds and it repeats forever?

lets say i have this line of codes #!/bin/bash xidel -se '//span[@class="last original"][1]' 'https://www.cnbc.com/quotes/?symbol=XAU=' exit 0 the output should be around 1,7K+ however, this script ...
CuriousNewbie's user avatar
0 votes
0 answers
26 views

BASH: How to calculate decimals using echo command? [duplicate]

by using echo command to calculate decimals like this one below: $echo $((1+1+2.1)) will produces this error below bash: 1+1+2.1: syntax error: invalid arithmetic operator (error token is ".1") so,...
CuriousNewbie's user avatar
1 vote
1 answer
542 views

What are sha1sum "exit codes"?

1) Is there any documentation/URL about sha1sum "exit codes"? I am just want to be sure, that "exit code 1" always means that there is a "FAILED result". $ sha1sum dummy* > SHA1SUM $ sha1sum -c ...
user avatar
2 votes
1 answer
130 views

Why basename with a suffix doesn't work in a subshell when used with find? [closed]

The following command doesn't do the subtitution, why? find ./ -name "*.dng" -exec echo `basename \{\} .dng` \; but this command work: find ./ -name "*.dng" -exec basename \{\} .dng \; What I'm ...
Fractale's user avatar
  • 1,522

1
634 635
636
637 638
3116