Skip to main content

All Questions

5 votes
2 answers
601 views

Bash reads quotes inside a variable as text, not quotes? Is "Implicit quoting" a thing in Bash?

I've got a bash script that cleans up the mail queue periodically. For Reasons, we've elected to delete any email to @mms.att.net and other email2SMS gateways that are over 9 hours in the queue and ...
Criggie's user avatar
  • 1,801
0 votes
1 answer
73 views

Using a variable in between ' 's

I have a bash script with a line that was originally this convert '%d.jpg[1-300]' combined.pdf Uses convert from Imagemagick to strap a load of sequentially numbered jpgs in to a PDF. I've written a ...
Big_James's user avatar
3 votes
1 answer
404 views

Why is "${1-"$var"}" (option 6 down below) not mentioned in POSIX?

The only reference I could find in the spec is this: It would be desirable to include the statement "The characters from an enclosed "${" to the matching '}' shall not be affected by ...
QuartzCristal's user avatar
1 vote
2 answers
341 views

Please explain the behavior of these parameter expansions using IFS?

I'm trying to figure out how to use the ${parameter%word} expansion with $@ and $*. It started by trying to make a script to combine pdfs using ghostscript, but I ran into some weird behavior with ...
mangoduck's user avatar
4 votes
2 answers
948 views

Bash's read builtin errors on a string-based timeout option specification but not an array-based one. Why?

In reading through the source to fff to learn more about Bash programming, I saw a timeout option passed to read as an array here: read "${read_flags[@]}" -srn 1 && key "$REPLY&...
qmacro's user avatar
  • 143
2 votes
2 answers
1k views

Removing single quotes from double-quoted variable element in array and run a command [duplicate]

I have a script where I dinamically change the arguments which must be passed to a command (mkvpropedit in this case). Consider the example script below: #!/bin/bash LANG_NAME="eng lish" ...
virtualdj's user avatar
  • 177
7 votes
3 answers
676 views

How would you gracefully handle this snippet to allow for spaces in directories?

I have a series of commands, e.g.: ssh -i key 10.10.10.10 mkdir -p "${DEST_PATH}/subdir1" "${DEST_PATH}/subdir2" rsync "${SOURCE_PATH}" "$DEST_HOST:${DEST_PATH}/...
JoeSlav's user avatar
  • 128
3 votes
1 answer
9k views

Escaping backlash and double quotes inside a sed expression (surrounded by double quotes)

$ echo 'output: " ' | sed "s/\"/\"/" output: " $ echo 'output: " ' | sed "s/\"/\\\"/" output: " $ echo 'output: " ' | sed "s/\&...
pi-star's user avatar
  • 33
-1 votes
1 answer
900 views

bash while loop irritate with single quote

I have a few lines code. I just want to check if argument $1 is in the file with a while loop so I write this code. #!/bin/bash if [ ! -z $1 ] then update=$1; while read line do if ...
Mahdi's user avatar
  • 19
3 votes
2 answers
954 views

Globbing within a parameter expansion

I'm trying to select the files within a set of directories passed as arguments with the following: ${@/%/*} However, this is not ideal, since paths with spaces will break, and quoting the parameter ...
Xerz's user avatar
  • 131
4 votes
2 answers
1k views

Is there a way to printf $@ verbatim?

I want to write a script that echoes to stdout its $@ verbatim, including any potential double-quotes, without a newline. What I have tried: > cat ./script1 #! /usr/bin/bash printf "%s %s" $0 ...
StoneThrow's user avatar
  • 1,797
6 votes
3 answers
9k views

How to prevent parameter expansion around a variable I want to be resolved?

Edit: Important note before reading further: since Kusalananda's anwser, my question is now quite useless, since he pointed out a bug in another script I used. Now this bug is fixed, the below errors ...
el-teedee's user avatar
  • 362
73 votes
1 answer
13k views

What is the difference between the "...", '...', $'...', and $"..." quotes in the shell?

Sometimes I see shell scripts use all of these different ways of quoting some text: "...", '...', $'...', and $"...". Why are there so many different kinds of quote being used? Do ...
Michael Homer's user avatar
0 votes
3 answers
2k views

Which quoting style GNU Bash variable definitions (mostly for paths)? [closed]

Which of the following quoting styles, for GNU Bash variables, is preferred and why? Two double quotes: VAR="/path/$V1/path with space/$V2". Multiple double quotes: VAR=/path/"$V1"/"path with space"/"...
Klorax's user avatar
  • 244
2 votes
2 answers
572 views

Using rsync to delete selected patterns, matches all files

I mean to use rsync to remove certain files (for Efficiently delete large directory containing thousands of files), in this case given to a shell script as patterns in the command line. So far, this ...
sancho.s ReinstateMonicaCellio's user avatar

15 30 50 per page
1
2 3 4 5
8