Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
2 answers
342 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
0 votes
1 answer
183 views

How to set sed command correctly

When I try following commands, (I'd like to rewrite sql). Day='2020/12/1' Dir=/home/test/data sql=`cat $Dir"/"$test".sql" | sed -e "s/Day/$Day/g"` I suffered following ...
Heisenberg's user avatar
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
2 votes
1 answer
81 views

Generating quoted command arguments

I'm working with a HTTP API that demands a very particular set of signed headers + JSON body. And I really want to cURL it for debugging and sanity in general. So, I've written a small script that, ...
Morten Siebuhr's user avatar
10 votes
1 answer
17k views

Using a variable as a case condition in zsh

My question is the zsh equivalent of the question asked here: How can I use a variable as a case condition? I would like to use a variable for the condition of a case statement in zsh. For example: ...
Smashgen's user avatar
  • 393
7 votes
1 answer
3k views

Why does `zip` in a for loop work when the file exists, but not when it doesn't?

I have a directory that contains several sub-directories. There is a question about zipping the files that contains an answer that I ever-so-slightly modified for my needs. for i in */; do zip "zips/...
Wayne Werner's user avatar
  • 11.9k
0 votes
2 answers
3k views

Wildcard not working in quotes

The script is supposed to loop over subdirectories and match all the filenames (FLA.*Image.*file.jpg and FLA.*Image.jpg) in subdirectories and process it. It also create output folder inside the ...
Tom's user avatar
  • 1
4 votes
1 answer
1k views

Problem with passing parameters containing spaces and wild card characters

I have a problem passing parameters if the parameters may contain wildcards and/or spaces, if those parameters are optional. Since this sounds pretty abstract, let's have a small example: The ...
user1934428's user avatar
181 votes
1 answer
78k views

When is double-quoting necessary?

The old advice used to be to double-quote any expression involving a $VARIABLE, at least if one wanted it to be interpreted by the shell as one single item, otherwise, any spaces in the content of $...
kjo's user avatar
  • 15.7k
3 votes
3 answers
968 views

Zsh function with su and echo

I'm trying to add a function to my .zshrc that makes adding new USE flags to my /etc/portage/package.use file easier. Normally, I'd have to do su -c 'echo "net-misc/aria2 bash-completion bittorrent" &...
user1002327's user avatar