Questions tagged [quoting]
Strings are typically delimited by quotes, which raises the problem of dealing with strings that include quotes.
1,075
questions
4
votes
1
answer
725
views
Quoting in a function results in error
How should I write the command variable to get the expected behavior?
#!/bin/bash
function f ( )
{
echo "$2"
}
command="f --option=\"One Two Three\" --another_option=\"Four Five Six\""
$command
...
2
votes
3
answers
393
views
How to pass lines from a file to a bash script, so that each line remains undivided, even if there are spaces?
Given:
$ cat lines.txt
a/b
'c/d e/f'
$ cat 1.sh
#!/bin/sh
./2.sh `cat lines.txt`
$ cat 2.sh
#!/bin/sh
echo p1=$1
echo p2=$2
echo p3=$3
$ ./1.sh
p1=a/b
p2='c/d
p3=e/f'
How do I change lines.txt or ...
2
votes
2
answers
897
views
Bash Script Argument Regex Group Conflict
I have a simple bash script:
input_dir="`dirname $1`/`basename $1`/"
output_dir="`dirname $2`/`basename $2`/"
ext=$3
...
...
...
echo -n `rename "-f" "'s/.*([0-9]{11}_[0-9]{11}).*\.(.*$)/$1.$2/'" "$...
11
votes
2
answers
21k
views
How to escape < or > in a parameter in shell?
I'd like to use grep with a PCRE expression that contains the < character. Bash thinks I want to redirect, but I don't want to. How can I escape <?
2
votes
2
answers
2k
views
Run ssh as a command of another ssh command
I want to run a program on a machine that I have ssh access to from a gateway machine that I can access with ssh too.
When I want to run an mpi program on the target machine T, I access to the ...
0
votes
3
answers
3k
views
Why can't I run this script?
$ sh bashtrrrrrr
# whats my pub. ip?
bashtrrrrrr: line 19: unexpected EOF while looking for matching `''
bashtrrrrrr: line 20: szintaktikai hiba: váratlan fájl vég
$ cat bashtrrrrrr
#!/bin/bash
...
6
votes
2
answers
535
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 this ...
2
votes
2
answers
484
views
bash quotes expansion puzzle
My script looks like:
opts="-x ''"
curl http://somepage $opts
I want the string in $opts appended to the command. I use bash -x test.sh to check the expansion and see that the the single-quotes are ...
5
votes
3
answers
6k
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} ...
5
votes
2
answers
46k
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 ...