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.
2,088 questions with no upvoted or accepted answers
6
votes
0
answers
2k
views
Execute script on external keyboard connection
EDIT: This is NOT a duplicate because the linked question is about external USB drives, not keyboards. The suggested command udevadm info -a -n sdb does nothing in helping to find the corresponding ...
5
votes
1
answer
646
views
bash + how to avoiding duplicate entries in authorized_keys (ssh) in bash
Popular methods of adding an ssh public key to a remote host’s authorized_keys file include using the ssh-copy-id command, and using bash operators such as >> to append to the file.
An issue ...
5
votes
0
answers
550
views
Is job-control really meant to be supported in subshells and scripts?
Small premise
I use subshells quite often to perform operations that involve changing the Shell Execution Environment, so as not to affect the main shell. I do it often from an interactive shell, and ...
5
votes
1
answer
546
views
How to create a real copy of file descriptor stdout and stderr without using unbuffer / script / tee just with bash built-ins?
My goal is to duplicate, redirect all output (stdout and stderr) of an
application (apt-get) to a file while retaining the usual behavior of
the application (apt-get), stdout and stderr.
How to ...
5
votes
0
answers
2k
views
Launch background process from sh and close the terminal
How can this be achieved in sh (not bash!)?
nohup sh -c 'helper-bcpy.sh "$0" "$1" "$2" "$3"' "$num" "$full_path" "$log" "$log_finished" >/dev/null &
I would have expected it to send the ...
5
votes
1
answer
2k
views
TOR hidden service not always accessible through cURL. Takes multiple tries
When I try to access a hidden service on TOR using cURL, for some reason I'm not getting access to the site 100% of the time. Many times it returns "curl: (7) Can't complete SOCKS5 connection to 0.0.0....
5
votes
2
answers
2k
views
Bash Script -- ffmpeg not being invoked as expected
I'm working on a bash script to convert my music library to ogg* but executing the right command is somehow eluding me. This is the line that should accomplish it:
ffmpeg -i "${file}" -f flac pipe:1 |...
5
votes
1
answer
448
views
How to overwrite file residing on ESP at Linux boot
I have a 64-bit dual-boot system running Windows 7 and Linux Mint 17 Cinnamon. I use rEFInd to graphically choose which system to boot.
A little bit about rEFInd:
It is an EFI bootloader.
It uses ...
5
votes
2
answers
713
views
dash maximum variable length under systemd
I have a shell script that uses a single variable as an associative array (one KEY=VALUE per line).
Throughout the execution of the script, the variable is manipulated to add, remove or modify ...
4
votes
0
answers
241
views
Why does bash $LINENO change inside an inner block in a function?
I'm trying to debug auto completion script located in /usr/share/bash-completion/bash_completion (bash completion package on every distro)
I did
export PS4='+'$'\t''$LINENO'$'\t # \t for proper ...
4
votes
1
answer
1k
views
Portable/POSIX way of getting range of arguments in shell script without shift
I thought I had found a portable or POSIX-compatible way of getting ranges of arguments in shell scripts, but I've forgotten it and I can't seem to find it again. I think its syntax looked like ${@:1} ...
4
votes
1
answer
425
views
Tool to edit CSS from script (better than `sed`)
I need to modify CSS file from a script and I want to make sure I don't break it.
Is there any command line tool that understands CSS structures and allows to edit them?
TLDR; I need jq command but ...
4
votes
1
answer
1k
views
Nested command substitution does not stop a script on a failure even if -e and shopt -s inherit_errexit are set
Suppose you have a following script sandbox.sh.
(This looks similar to Command substitution inside a function does not stop the script on a failure even if -e is set, but I believe a bit different ...
4
votes
3
answers
695
views
Parsing csv file to filter rows based on a matching set of characters from a column value
Consider the following csv file:
A,3300
B,8440
B,8443
B,8444
C,304
C,404
M,5502
M,5511
The actual csv file is big (around 60,000 rows). I have only included a small version to describe ...
4
votes
0
answers
5k
views
Bash script calls python script that wants interactively input ( not only arguments )
I have a bash script bash.sh that looks like this:
#!/usr/bin/env bash
/usr/local/sbin/pythonScript.py firstArgument secondArgument
If I call the pythonScript.py from my terminal with the two command ...