Questions tagged [bash]
Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead. For shell scripts with errors/syntax errors, please check them with the shellcheck program (or in the web shellcheck server at https://shellcheck.net) before posting here.
27,277 questions
3
votes
3
answers
82
views
move files to directory according to prefix
I'm in the following situation
> ls
H9/ HG01109_chr1_hap1_contigs.list HG01952_chr1_hap2_contigs.list HG02572/ HG03486_chr1_hap1_contigs.list
...
0
votes
0
answers
11
views
Launching Browser in Wayland/Cosmic w/ bash script as "non-steam" game in steam doesn't transfer ownership of controller or allow for the overlay
The situation:
I've been converting my family to Linux for quite some time now. I'm currently in the process of replacing their Roku with a Media PC (in this specific case, Pop_OS! 24.04 using Wayland ...
5
votes
2
answers
600
views
Are some bash ambiguous job specs impossible to differentiate?
$ sleep 1234&
$ sleep 12345678&
$ %sleep\ 1234
bash: fg: sleep 1234: ambiguous job spec
$ jobs
[1]- Running sleep 1234 &
[2]+ Running sleep 12345678 &
...
0
votes
0
answers
38
views
bashrc not sourced when running "bash -l", on just one raspberry pi trixie system
Description
I have two Raspberry Pi OS 13 (Trixie) systems with identical Bash versions and identical /bin/bash binaries (verified with md5sum). On one system, running bash -l sources ~/.bashrc as ...
0
votes
0
answers
42
views
setting and using a shell variable inside "sudo -i bash -c" [duplicate]
I have a little maintenance thing to do as super user, from time to time. I would like that to be a one-liner, for easy copying from my self-documentation to a terminal. I reduced it to the bare ...
0
votes
0
answers
36
views
Cannot understand variable assignment logic in bash function [duplicate]
I created this function, which is supposed to allow an interactive selection of an mDNS hostname, and then connect to it via ssh.
Yet, whatever I try, the host variable is only available in side the ...
0
votes
1
answer
65
views
How to move the cursor to an embedded newline on the bash command line? [duplicate]
I have just pasted a line into the bash shell.
It contains embedded newlines.
CTRL+a gets me to https at the start.
CTRL+e gets me to 7d87 at the end.
How can I move around from line 1 to 2 to 3 ...
3
votes
2
answers
338
views
Bash/Dash - Catching the error when calling set
I'm writing a script and I'd like to use set -o pipefail on shells that support it. Dash does not support that option. Usually, || true lets me swallow errors, but not in case of set:
> podman run ...
1
vote
1
answer
42
views
Cancel just second command of bash logical AND operator [duplicate]
It often happens that I have some long task running, like compiling a program, running tests or copying large archives. Once I am done with whatever else I was doing, I want to leave the computer ...
5
votes
2
answers
869
views
POSIX sh alternative to using [[ ... ]] in Bash
I am using this code to parse the first argument passed to my script. It error handles and it works just the way I want it:
if [ -z "$action" ]; then
printf "[${c_RED}ERROR${c_RESET}...
0
votes
1
answer
71
views
disable bash job control warning "job specification requires leading `%'"?
I just rebooted one of my systems for the first time in several months, restarted tmux and my usual set of bash shells for tailing various log files, and noticed that running fg n (i.e. fg followed by ...
2
votes
3
answers
199
views
bash syntax: what does '[@]+' mean? [duplicate]
I have a script that parses command line arguments.
The intro to the loop to iterate over the argument array looks like this:
for arg in ${args[@]+"${args[@]}"}; do
Can someone explain this ...
3
votes
6
answers
425
views
How can I use sed to chain append lines from a text file, add it as a suffix to the text on the same lines numbers on another file, and so on?
I've tried using sed for this. I've tried putting the lines of interest in variables as well.
I have two examples I want to achieve for now. Lets say I have thousands of urls in a file called links....
0
votes
0
answers
67
views
how to convert hex memory dump to Docsis config file?
Hex memory dump is Docsis config file. Is it possible to convert this hex dump info valid Docsis config file? Preferably, using Perl and DOCSIS::ConfigFile module. (or Python scripts, python-docsis). ...
3
votes
3
answers
913
views
How do I ensure a bash script argument is a specific value?
The following script is supposed to check $1 and see if it is a specific value. It only works when one Bash [[... =~ ...]] regex check is passed in an if statement.
The error is: When more than one ...