Linked Questions

8
votes
3answers
4k views

What is the difference having double quotes or not in bash [duplicate]

I have some bash scripts, one which has the following content: #!/bin/bash source $(dirname ${BASH_SOURCE[0]})/script.sh while the other one has the following content: #!/bin/bash source "$(dirname ...
4
votes
1answer
10k views

when to use double quotes with a variable in shell script? [duplicate]

I am in a confusion with what is meant by the double quotes referring to a variable. For example following two scripts gives the same output. What is really meant by the double quotes? Script1 ...
5
votes
1answer
2k views

Any problem assigning one variable to another in shell without using quotes? [duplicate]

This question is about assigning the entire contents of one variable to another variable. Variable is not being used (sent to echo, etc.) No parameter expansion is being done during the assignment. ...
0
votes
2answers
10k views

mkdir using variables [duplicate]

I am having issues creating dirs using a variable in a script. Ex: read user mkdir $user{01..10} Interestingly, it will work like this: read user mkdir {01..10}$user Any way to get around this, or ...
1
vote
1answer
2k views

What is the difference between $var and “$var”? [duplicate]

Possible Duplicate: $VAR vs ${VAR} and to quote or not to quote I assigned a variable var a value as follows: pradeep@pradeep-laptop:~$ var="Pradeep > is > a good > boy" Then I ...
0
votes
2answers
365 views

What is the best practice between using ${var} or $var? [duplicate]

I know that ${var} and $var does the same thing. I also know that you can use brace for advanced options like ${var:=word} or ${var#pattern}. It's also explained here. But I see in some bash scripts ...
1
vote
1answer
294 views

what is diffrence between “$var” and “${var}” [duplicate]

i have seen in many script usage of "$var" and "${var}", so I just want to know diffrence between "$var" and "${var}"
0
votes
1answer
145 views

linux + .bash_profile + correct PATH syntax [duplicate]

regarding the file: .bash_profile what is the different between PATH=${PATH}:${HOME}/bin:/usr/local/ to PATH=$PATH:$HOME/bin:/usr/local and what is the correct syntax?
0
votes
2answers
50 views

Passing variables to script [duplicate]

What is the difference between: ./script.sh "$VARIABLE" and ./script.sh ${VARIABLE} Is there any?
121
votes
3answers
96k 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 ...
116
votes
1answer
40k 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 $...
34
votes
2answers
7k views

Are quotes needed for local variable assignment?

Can I safely omit quotes on the right side of a local assignment? function foo { local myvar=${bar} stuff() } I'm mainly interested in bash, but any info on corner cases in other shells are ...
16
votes
3answers
81k views

How can I concatenate a shell variable to other other parameters in my command lines ?

How can I concatenate a shell variable to other other parameters in my command lines? For example, #!/bin/sh WEBSITE="danydiop" /usr/bin/mysqldump --opt -u root --ppassword $WEBSITE > $WEBSITE....
9
votes
7answers
8k views

Splitting large directory tree into specified-size chunks?

I have a directory tree that I would like to back up to optical disks. Unfortunately, it exceeds the size of any one disk (it's about 60GB). I am looking for a script that would split this tree into ...
10
votes
2answers
10k views

What is PATH on a Mac OS?

What is the PATH in a Mac OS? I have used it to install global command-line tools, but the only documentation I have found are tutorials for doing just that, with no real explanation of what is ...

15 30 50 per page