Linked Questions

5
votes
3answers
403 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 ...
1
vote
1answer
315 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" ...
1
vote
1answer
84 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
149 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 ...
6
votes
3answers
21k 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 > ...
15
votes
2answers
328 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 ...
8
votes
7answers
3k 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 ...
6
votes
3answers
624 views

Why I can't escape spaces on a bash script?

I'm trying to escape the space char for a path in Bash, but neither using a backslash or quotes works. .sh script: ROOT="/home/hogar/Documents/files/" FILE=${ROOT}"bdd.encrypted" ...
4
votes
3answers
3k views

Why the double quotes and backquotes in a shell script?

I'm looking at this script mysql backup script and I don't understand what is the reason for using both backticks and double quotes around command names? 379 WHICH="`which which`" 380 AWK="`${WHICH} ...
1
vote
2answers
1k views

Creating an empty file having a variable name in a script

I need to create an empty file using a shell script. The filename will be determined by examining all the files in a directory matching a pattern, say TEST.*, and appending _END to it so that the new ...
5
votes
2answers
313 views

Bash, curious about echo $variable

I was hacking at a small script earlier and noticed something I can't explain. Running this command (time wget --spider http://www.google.co.uk/) 2>&1 | egrep 'real|response' gives me ...
0
votes
2answers
578 views

$(tail) into variable removing \n

I am doing the following: x="Hello to the world of tomorrow\n <pre>"; x="${x}$(tail -n 50 log/logfile.log)" x="${x}</pre>"; echo -e $x | ./perlscript The Perl script: #!perl # ...
1
vote
1answer
150 views

bash script disapearing variable

I have created a small script to move video files from a helmet mounted camera to my mythbuntu machine and there is a variable that for some reason will just not be passed onto the script. The ...
-1
votes
3answers
1k views

printf white space character in bash script

How can the white space character be escaped in printf for the purpose of this script that currently runs in a Cygwin client? The line containing the whitespace (which by itself works from the command ...
-1
votes
1answer
1k views

How to move file from one folder to another in shell script by changing the permission

I want to move a file from one folder to another folder. When the file's format is with space in between (file _name.dat) and when I am using the command mv file _name.dat /tmp then the file is not ...
2
votes
3answers
423 views

Quote a variable in shell script “if” statement

e.g. if [ "$FOO" = "true" ]; then vs if [ $FOO = "true" ]; then What is the different? Seems both of two statements also works.
1
vote
1answer
887 views

Concatenate multiple strings with spaces in them?

I am trying to do the following in ksh shell: JMX_ROOT=/bfs-build/build-info/mep_mainline-Linux.latest/core/mainline/automation SMOKE_JMX_LOCATION="$JMX_ROOT/\"Smoke Set\"/*.txt $JMX_ROOT/\"Smoke ...
1
vote
1answer
572 views

Outputting last modification date to another file?

I'm trying to read the number of lines in a file, and the last modification date of that file (e.g. if it was last modified Jan 18, 2013, it should output 2013-01-18), then append the data to the ...
3
votes
2answers
203 views

open a file using CDPATH and symlink

To quickly move around, I added a path to CDPATH that contains symlinks to different locations. I did this by adding the following line to .bashrc: export CDPATH=~/symlinks When working with ...
1
vote
1answer
312 views

Shell variables not working?

I'm trying to store the date in a variable ($DATE) so I can use it later, but it doesn't seem to work. See anything wrong? DATE=$(date +"%Y-%m-%d %R") sudo mysqldump -u root -pnotgivingyoumypassword ...
4
votes
2answers
109 views

Shell Script to isolate files scattered in different folders

I need to write a shell script that traverses a given directory structure in multiple levels, recognizes the video files scattered in the folders and copies all of them to another single folder. The ...
3
votes
2answers
142 views

Bind locally installed library

I have no root-acces on a machine and i'm trying to install a library called GiNaC locally in my home folder. I use this tutorial http://www.ginac.de/tutorial/Configuration.html#Configuration. At the ...
2
votes
2answers
75 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 ...
1
vote
1answer
74 views

Read a variable with “read” and preserve backslashes entered by the user

I'm using read to read a path from a user like so: read -p "Input the file name: " FilePath The user now enters this string: \Supernova\projects\ui\nebula What can I do to replace \ with /. The ...
1
vote
2answers
86 views

viewing variable values in a KSH script

I am using a KSH script that creates numerous variables from fairly complex code. What command can I place in the script to view the value of these variables as they are created? Would ECHO be the ...