Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
0 votes
0 answers
82 views

I'm trying to pass a command through to ffmpeg, but I'm struggling to get it to work with spaces in the name. I've tried this: filters="-vf subtitles='$filename.$format':force_style=Fontsize=24&...
Cestarian's user avatar
  • 2,593
1 vote
1 answer
126 views

In Visual Code, on Windows 10, I'm trying to create a function for my .sh project (which I run with Git Bash), which will report errors to the console in case user, let's say, provides fewer or more ...
Simos Sigma's user avatar
0 votes
0 answers
40 views

https://www.gnu.org/software/bash/manual/html_node/Quote-Removal.html 3.5.9 Quote Removal After the preceding expansions, all unquoted occurrences of the characters ‘\’, ‘'’, and ‘"’ that did ...
Martian2020's user avatar
  • 1,501
5 votes
1 answer
357 views

https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html When braces are used, the matching ending brace is the first ‘}’ not escaped by a backslash or within a quoted string,...
Martian2020's user avatar
  • 1,501
10 votes
3 answers
2k views

I use the Git Bash on Windows, and stumbled over a strange behaviour. When I execute this command, it creates an empty file: echo hello | > hello.txt (hello.txt is empty after this command) I ...
daniel kullmann's user avatar
4 votes
2 answers
734 views

I'm trying to find the "right" way to read files line-by-line. I have been using for for line in $(cat "$FILE"); do for a while, and I really enjoy its clearness. I know that while ...
atis's user avatar
  • 43
0 votes
1 answer
67 views

While writing a backup Bash script, I've copied files from an APFS file system to an external drive that is HFS+ (I don't want to convert it to APFS because sometimes I need to read/write files with ...
zakmck's user avatar
  • 143
0 votes
1 answer
453 views

I'd like my log files to be named after a variable. Since this isn't possible: #SBATCH --output some_software.${var}.out #SBATCH --error some_software.${var}.err I came across this work around but ...
Caterina's user avatar
  • 103
0 votes
1 answer
74 views

Can anyone explain what's going on with DR here? user@host:~# DRYRUN=true user@host:~# echo "$DRYRUN" true user@host:~# $DRYRUN && export DR="-n" user@host:~# echo $DR user@...
Hugh's user avatar
  • 19
0 votes
0 answers
49 views

For a school project, I am tasked with making my own (simplified) shell, with bash being the reference point. This includes replicating heredoc behavior which was fun until I stumbled upon variable ...
Mika's user avatar
  • 101
0 votes
0 answers
105 views

Opening vim while recording with script causes script to go wild (my screen starts filling up with a bunch of crap, some of which says "script", and I also believe it is colored neon green). ...
leeand00's user avatar
  • 4,971
3 votes
1 answer
337 views

I have a Bash function that follows the fzf key-bindings in key-bindings.bash. # shellcheck disable=SC2206 __fzf_edit_file__() { builtin local -a opts builtin local edit_file file opts=( &...
Jetchisel's user avatar
  • 1,574
4 votes
1 answer
772 views

How can I remove special non-characters e.g. faces, avatars, emojis, symbols that are not part of national alphabets from filenames while keeping any national alphabets intact? e.g. ...
Estatistics's user avatar
3 votes
1 answer
245 views

I'm trying to make an alias or a function that will execute a shell script or a file without holding up a terminal. So far I've figured out a command that'll do that, but I'm having trouble turning it ...
Nerys Halcyon's user avatar
1 vote
1 answer
179 views

I answered a recent question using the RETURN trap to store the name of the last function executed. I wanted to enhance it to also save the exit status and discovered that wasn't as easy and I couldn'...
Ed Morton's user avatar
  • 36k
2 votes
4 answers
227 views

I want to line up a couple of Bash functions based on the success or failure of the execution of the preceding function. If something fails, I want to print an error message: function_x has failed. ...
vrms's user avatar
  • 287
4 votes
0 answers
113 views

Why does echo "$(fc -l -1)" show the previous command, but echo "$(fc -l -1 | cat)" show the current command? $ testfc () { > echo "$(fc -l -1)" > echo &...
Jacktose's user avatar
  • 532
0 votes
0 answers
33 views

RHEL 8. $ alias suip alias suip='sudo -iu postgres' If I specify the complete filename, the ls command works as expected: suip ls ~postgres/logs/pgbackrest_2025-04-30_01:00:01_incr.log /var/lib/...
RonJohn's user avatar
  • 1,483
1 vote
1 answer
177 views

I'm trying to break a long command substitution on to multiple lines, as discussed in this answer. In a plain command pipeline, both explicit (\) and implicit line continuation work fine: $ echo 'blah ...
Jacktose's user avatar
  • 532
0 votes
0 answers
38 views

I have a script which is supposed to fetch 2 URLs sequentially: #!/bin/bash wget_command='wget --restrict-file-names=unix https://www.example.com/{path1,path2}/' $($wget_command) echo $wget_command ...
MonkeyZeus's user avatar
0 votes
0 answers
33 views

I've seen questions about this topic, but they talk about constructs like if or ||. I don't understand why the same behavior seem to happen for substitution ($())? $ my_function() { echo "the ...
Jakub Bochenski's user avatar
1 vote
0 answers
60 views

I have a command (systemctl status) that halts and waits for keystrokes if I run it in a terminal that is not tall enough. I'm not interested in this behavior and can't find an option to bypass it. If ...
xenoid's user avatar
  • 9,348
0 votes
3 answers
126 views

I have a string of text and spaces which looks like this: macOS windows arch-linux ubuntu_linux I want to append each item (with whitespace denoting a break between items) to a bash array. How do I ...
EmberNeurosis's user avatar
2 votes
1 answer
173 views

I want to edit a file before feeding it into an array. The data file contains: Line 1 Line 2 Line 3 If I read it with mapfile -t direct < data I obtain a 3-element direct array But I pipe the ...
xenoid's user avatar
  • 9,348
0 votes
1 answer
120 views

How to make bash not set the underscrore _ variable for the processes that it's starting? Explanation of what it is if you haven't encountered it before: If you launch env from bash, you'll see the ...
VasyaNovikov's user avatar
  • 1,569
0 votes
1 answer
115 views

In a larger script I have trap -p echo "settings: [$-], command: [$*]" "$@" echo "return code $?" and I get the output trap -- '_shunit_cleanup EXIT' EXIT trap --...
Harald's user avatar
  • 1,050
6 votes
4 answers
988 views

If we do: VAR=100:200:300:400 We can do: echo ${VAR%%:*} 100 and echo ${VAR##*:} 400 Are there any equivalents I could use to get the values of 200 and 300? For instance, a way to get only what's ...
Cestarian's user avatar
  • 2,593
-3 votes
1 answer
168 views

In Linux with Bash, there is the File numbers_in_one_line. In this file there is only one line with several numbers, all separated by spaces. These numbers are the value in bytes for creating files ...
user447274's user avatar
-2 votes
2 answers
138 views

I am trying to determine the number of unique web visitors to my website each hour. The log files (access*.log) contain many lines looking similar to this. 192.168.211.85 - - [29/Sep/2024:10:17:02 -...
kojow7's user avatar
  • 305
0 votes
1 answer
1k views

So I ran into the following interesting problem: I tried to define XDG_RUNTIME_DIR in my .bashrc as follows: export XDG_RUNTIME_DIR=$MY_HOME/.local/share After doing this I noticed my pactl cli ...
glades's user avatar
  • 126
0 votes
1 answer
122 views

I know bash tries very hard to keep new versions compatible with previous ones. However they sometime introduced (minor, but still) breaking changes: for exemple when we could no longer have : { foo }...
Olivier Dulac's user avatar
3 votes
1 answer
84 views

When I run the following code declare -A X # get an associative array index="a'b" # a somewhat weird index X[$index]="this is set" echo "<<${X[$index]}>>" if ...
Harald's user avatar
  • 1,050
14 votes
1 answer
3k views

Maybe I'm missing it, but I don't find it documented that cd '' should succeed. Since there is no directory with the name '', it seems obvious that it should fail. For example, mydir= cd -- "$...
jrw32982's user avatar
  • 1,099
2 votes
2 answers
173 views

There is an answer from SuperUser, which renames filenames containing whitespace: for f in *\ *; do mv "$f" "${f// /_}"; done The part I don't understand is *\ *. The author wrote ...
glacier's user avatar
  • 490
2 votes
1 answer
274 views

First, I do know this is a security risk. I do know about ssh keys and sshpass. This belongs to a fun project. I wondered if a bash Here-Document could be used as a password input for ssh. I ...
Simon Huenecke's user avatar
-3 votes
1 answer
174 views

Even though bash -n is a valid and widely used option, some manpages don't clearly document it in the bash options section, even though it is implemented. It's also not in the GNU Bash Reference ...
bit's user avatar
  • 1,196
5 votes
6 answers
2k views

Try to run this mv -- "foldername...__" "foldername..." This will move folder foldername...__ under the folder foldername... instead of renaming it. Why? Note that foldername... ...
Estatistics's user avatar
0 votes
1 answer
115 views

In Linux in Bash, there is a script, a part of the script is this while true ; do echo awk -v x=$(<"$TEMPDIR"size_container_in_byte) -v n=$(<"$TEMPDIR"parts) 'BEGIN{...
user447274's user avatar
0 votes
1 answer
261 views

I have my own implementation of a Redis server which I'd like to test through a shell script. The general idea is to feed it with some commands through nc, and since nc prints the output of my program ...
ivanbgd's user avatar
  • 111
4 votes
1 answer
315 views

Lets define a shell function (here the shell is Bash) and test it $ s () { xterm -e sleep 5 & } $ s [1] 307926 $ [1]+ Done xterm -e sleep 5 $ With my specific meaning of ...
gboffi's user avatar
  • 1,406
2 votes
2 answers
779 views

A bash command: $(System.DefaultWorkingDirectory)/yq_linux_amd64 '. *= load("${{ parameters.HELM_CHART_PATH }}/values/DEV/${{ parameters.COMPONENT }}.yaml")' ${{ parameters.HELM_CHART_PATH }}...
Mihir's user avatar
  • 47
0 votes
2 answers
7k views

What is the standard way, in bash, to check if an environment variable is set up? I'm a little confused between the following options: ! [ -z "${VAR}" ] [ -n "${VAR}" ] [ "${...
kj-crypto's user avatar
  • 119
3 votes
1 answer
1k views

I have a BASH pipeline which at a point runs a Singularity container with singularity exec as follows: singularity exec --bind `pwd`:/folder --bind $d:/results <image>.sif <tool_command> -...
Matteo's user avatar
  • 387
0 votes
2 answers
149 views

Following this post I created my own version of the script, with the difference that user and password are forwarded from the environment variables: #!/bin/zsh pamtester login $user authenticate <&...
Namal's user avatar
  • 101
1 vote
2 answers
115 views

I have a script which implements a simple menu using dialog (an ncurses app for generating TUI widgets). This runs immediately after boot on an Arch-based system. The dialog script works when ...
QF0's user avatar
  • 401
3 votes
1 answer
185 views

Please confirm/correct me. I've found related Duplication of file descriptors in redirection but that does not answer my specific question. From the The GNU Bash Reference Manual, section 3.6 ...
Martian2020's user avatar
  • 1,501
0 votes
3 answers
249 views

I have a script that runs a program that I only want to run as a single instance per-script. For example, I have a script "a" and a script "b", which each runs a Java program. I ...
Zhro's user avatar
  • 2,861
0 votes
1 answer
77 views

I'm trying to filter bash-completion suggestions. Here awf-gtk2 -s abc.png [TAB] display -h --help -s --screenshot (it's ridiculous) / and awf-gtk2 -s[TAB] add a space after -s (perfect), with: ...
luigifab's user avatar
  • 101
0 votes
2 answers
166 views

I probably approach this problem wrong. I update my Linux machines with bash aliases like: alias upg-pi='\ssh -c [email protected] -C -i $ssh_identity -o ConnectTimeout=$ssh_timeout root@$...
Vlastimil Burián's user avatar
2 votes
1 answer
218 views

With the function function fail() { local msg="$*" echo $msg at for i in ${!FUNCNAME[@]}; do echo " ${FUNCNAME[$i]} ${BASH_SOURCE[$i]}:${BASH_LINENO[$i]}" done exit ...
Harald's user avatar
  • 1,050