Questions tagged [shell-script]
Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.). Check scripts with https://shellcheck.net before posting.
16,777 questions
1
vote
1
answer
48
views
Docker Container Mount Name, Type and other values
I am writing a bash script and I am aware that I can get information of the mounts attached to a container using docker inspect --format '{{.Mounts}}' <container-name> which gives a result such ...
-1
votes
0
answers
49
views
Install Linux from the command line
I have made a Linux From Scratch and built a command line from it. I also wrote a script in /usr/sbin named install-command-line. When I want to install Linux, I just have to open a terminal in the ...
0
votes
2
answers
84
views
What explains the measured overhead when timing a command in zsh?
When timing a command with time, there is inevitably some overhead (from the CPU, operating system, shell and so on).
Running the following code, from a tty text mode virtual console with all ...
6
votes
2
answers
274
views
Change some file names during a backup with rsync
I use a simple backup bash script to copy some directories originally placed in a Debian (Testing) from a USB stick (formatted NTFS) to a MacBook. The names of directories are the same from origin to ...
-4
votes
1
answer
219
views
How to redirect command output to a file if the command itself contains redirection
In the below shell script I'm executing the some command cmd remotely where in the command output is redirected to some file cmd_log. I'm getting the desired result as long as the command cmd itself ...
7
votes
3
answers
908
views
With `#!/bin/sh`, what is the closest to `;;&` (`bash`'s fallthrough)?
Without ;;&, /bin/sh gives Syntax error: ")" unexpected (expecting ";;").
;;& triggers shellcheck's ^-- SC2127 (error): To use cases with ;;&, specify #!/usr/bin/env ...
2
votes
1
answer
188
views
`printf` and `time` formatting issues in a `zsh` shell script
I have the following (excerpt from a) zsh shell script (the FOLDER environment variable is exported earlier in the code):
# Create temporary directory
export TMPDIR=$(mktemp -d)
# Set TIMEFMT to ...
0
votes
0
answers
71
views
A bash script problem installing Apache Cloudberry - it's a generic setup script - just isn't working for me
This is a fairly bog-standard script, but my bash knowledge isn't huge, so here goes.
The script is from here - the Apache Cloudberry project - an interesting open source version of a distributed ...
2
votes
4
answers
143
views
Is it possible to silence the initial call in xtrace, when BASH_XTRACEFD is set?
#!/usr/bin/env bash
exec {BASH_XTRACEFD}>./xtrace.log
declare -p BASH_XTRACEFD
set -x
{ : "how do you hide this in ./xtrace.log?"; } 2>/dev/null # fail
# { :; } "${BASH_XTRACEFD:-...
-2
votes
1
answer
121
views
extract fields of a string separated by |
In the below shell script I want to extract the fields of a string delimited by | character. But unfortunately I'm facing issue if there exists pipe command | in the string, because of which I'm not ...
1
vote
2
answers
326
views
get process id of a process running in remote machine
In the below shell script, I am trying to get the process id of a remote process using ps command, but not getting the required output
#!/bin/bash
get_process_id() {
local res
local ...
0
votes
5
answers
771
views
Extract email addresses from line, with multiple email addresses per line
I have a text file that mixes names and email addresses, in a comma-separated list.
First Person <[email protected]>, Second Person <[email protected]>, Third <[email protected]>
...
-4
votes
2
answers
185
views
Linux kill command returns "No such process"
In the below shell script I have list of process IDs which need to be killed. When killing a process I am getting kill: 1234567: no such process error even after checking if the process id existence ...
-3
votes
3
answers
107
views
How to pass an array as an argument to a function
In the below shell script I am passing an integer and a string array to a print function which should print each parameter separately, but I'm not able to. I don't want make a reference of passed ...
-2
votes
3
answers
153
views
Generate hashes automatically and continuously with a script and stop by pressing a key?
I need a part for a script in bash where hashes are generated automaticaly and continuously and when I press a key the generation stops and the last hash at which I stopped is displayed.
I've cobbled ...