Linked Questions
338 questions linked to/from When is double-quoting necessary?
1 vote
0 answers
58 views
Is there any point in quoting simple strings? [duplicate]
Is there any reason for doing something like: a="abc" or a='abc' The quotes seem completely superfluous, but then there might be some hideous corner case... I'm interested in Bash and Sh in ...
1 vote
0 answers
39 views
Should I quote variable when passing to command? [duplicate]
I always do this when passing variable to command mkdir -p "$dir_to_make" are those quotes needed? I tried to google but didn't find much. I always write them, just interested if they are necessary.
0 votes
1 answer
48 views
How to make emacs start in bash by visiting a find command result containing whitespace in its name and double quotes in path? [duplicate]
I'm confronted with an escape challenge: The process: Step 1 - the file retrieval: Within bash, find command will be invoked. Find commands output is 1 single file with a path like this: ./vacation/...
0 votes
0 answers
37 views
Directories printed instead of */ [duplicate]
I have a file like this /* Created by Bla bla bla Copyright by XYZ December 20th, 2020 */ "car" = "Carro"; "door" = "Porta"; I would like to read ...
0 votes
0 answers
43 views
Why does `if [ -d $EMPTY_VAR ]` return true? [duplicate]
I have written a Bash script which doesn't behave quite as I expected. It contains the following lines of code. TARGET_FOLDER=$1 echo "TARGET_FOLDER: $TARGET_FOLDER" if [ ! -d $TARGET_FOLDER ...
0 votes
0 answers
32 views
awk output not in columns when moved to log [duplicate]
I have an awk command piped to the output of another command | awk {'print $2,$3'}. When I run this command the output displays the data in columns, of the columns as I would expect column2 column3 a ...
0 votes
0 answers
28 views
Get immediate folder of file using find (issue with spaces) [duplicate]
I'm trying to search my Movies folder to find the immediate folder of the .MKV file I'm searching for. The below works (echo 5) to save the immediate folder as a variable, BUT, it does not work if $...
0 votes
1 answer
45 views
What are the differences in the way to get the value of a single environment variable? [duplicate]
I know the typical way is echo "$PATH", for example. But echo $PATH also works. Also, you don't need the echo command even, you can just type $PATH, and the value of path will be outputted ...
0 votes
0 answers
26 views
Save renamed name as variable [duplicate]
I am using Gammu for receiving SMS. Once received I am sending them as emails. Yet if sender ID of the SMS contains space, my script is unable to process a file. I.e.: If the file name is ...
0 votes
0 answers
25 views
Quoting inside [[ ]] in bash shell [duplicate]
Inside [[ ]] I do not need to quote variables right? Rather than if [[ "$flrm" == *"org"* || "$flrm" == "all" ]]; then printf '%s\n' "Delete: $fl" ...
0 votes
0 answers
19 views
Difference between echo $(cal) and echo "$(cal)" [bash] [duplicate]
I'm a linux noob. When I type echo $(cal) in bash it prints calendar without any formatting. But when i type echo "$(cal)" it prints the complete formatted calendar. What is the distinction ...
0 votes
0 answers
17 views
String formatting in bash script won't work [duplicate]
I am working on a self project which is an API server. I am trying to test my api routes using curl command with bash scripts. The curl commands for post requests are pretty long so I want to use a ...
0 votes
0 answers
15 views
`zsh` and `bash` handle command output differently [duplicate]
In zsh: % RESPONSE=$(ping -c 1 raspberrypi4b.local) % echo $RESPONSE | grep "% packet loss" 1 packets transmitted, 1 packets received, 0.0% packet loss But in bash it's different: $ RESPONSE=$(...
1412 votes
12 answers
3.7m views
How to correctly add a path to PATH?
I'm wondering where a new path has to be added to the PATH environment variable. I know this can be accomplished by editing .bashrc (for example), but it's not clear how to do this. This way: export ...
320 votes
12 answers
588k views
How can I test if a variable is empty or contains only spaces?
The following bash syntax verifies if param isn't empty: [[ ! -z $param ]] For example: param="" [[ ! -z $param ]] && echo "I am not zero" No output and its fine. But when param is ...