Linked Questions

2
votes
2answers
223 views

Why is it not required to double quote `$bar` in assignment `foo=$bar`? [duplicate]

From https://unix.stackexchange.com/a/32227/674 The main places where it's safe not to use the double quotes are: in an assignment: foo=$bar (but note that you do need the double quotes in ...
1
vote
0answers
47 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 ...
124
votes
3answers
98k views

Quoting within $(command substitution) in Bash

In my Bash environment I use variables containing spaces, and I use these variables within command substitution. Unfortunately I cannot find the answer on SE. What is the correct way to quote my ...
136
votes
4answers
47k views

$VAR vs ${VAR} and to quote or not to quote

I can write VAR=$VAR1 VAR=${VAR1} VAR="$VAR1" VAR="${VAR1}" the end result to me all seems about the same. Why should I write one or the other? are any of these not portable/POSIX?
30
votes
2answers
2k views

Where is “export var=value” not available?

I have picked up -- probably on Usenet in the mid-1990s (!) -- that the construct export var=value is a Bashism, and that the portable expression is var=value export var I have been advocating ...
15
votes
2answers
9k views

Using shell variables for command options

In a Bash script, I'm trying to store the options I'm using for rsync in a separate variable. This works fine for simple options (like --recursive), but I'm running into problems with --exclude='.*': ...
6
votes
4answers
1k views

back ticks vs double quotes

I've been wondering this for a long time but haven't figured out how to look it up - is this: x=`command -v r2g` the same as this: x="$(command -v r2g)" or is it the same as this: x=$(command -...
-2
votes
3answers
5k views

How to add more directiories in PATH [closed]

Okay, first thing first, I'm new to Linux and I'm using Linux Mint. I learned that when I want to add more directories to my PATH (specifically my home directory) I need a Bash command that looks ...
1
vote
2answers
2k views

Saving Output In a Variable and Re-using it

page=`grep $x /var/www/vhosts/example.com/statistics/logs/access_log | awk '{print $7}'| sort |uniq -c |sort -nr` times=`$page | wc -l` I am trying to save output of grep in a variable as page. But ...
0
votes
2answers
3k views

ls, mv, cp, cat, vi, command not found

I was trying to add a new path to my bashrc file but I have seemed to messed something up. after I $ source ~/.bashrc I no longer can use the commands ls, mv, cp, cat, vi, and probably others that I ...