All Questions
6
questions
129
votes
4
answers
52k
views
Why does parameter expansion with spaces without quotes work inside double brackets "[[" but not inside single brackets "["?
I'm confused with using single or double brackets. Look at this code:
dir="/home/mazimi/VirtualBox VMs"
if [[ -d ${dir} ]]; then
echo "yep"
fi
It works perfectly although the string contains a ...
148
votes
11
answers
55k
views
What is the difference between $* and $@?
Consider the following code:
foo () {
echo $*
}
bar () {
echo $@
}
foo 1 2 3 4
bar 1 2 3 4
It outputs:
1 2 3 4
1 2 3 4
I am using Ksh88, but I am interested in other common ...
10
votes
2
answers
24k
views
How do I escape a sub-directory name with an ampersand in it?
Running a kornshell and trying to traverse a directory tree.
Want to cd to a sub-directory named as follows:
-3ab_&_-3dc.img
My question is HOW do I need to escape the ampersand in this name?
I'...
2
votes
2
answers
734
views
Meaning of \ before environment variable
In ksh on an old Solaris box I used:
export PS1="$PWD $"
to set the prompt to the current directory. It works great until you cd elsewhere, then you see that it's not evaluating PWD each time. I ...
22
votes
2
answers
1k
views
Why escape trivial characters in shell script?
I just opened a legacy shell script (written in old ksh88 on Solaris) and found the following repeated all throughout the code:
[ -f $myfile ] && \rm -f $myfile
The escaping backslash ...
5
votes
3
answers
3k
views
quotes inside backticks inside quotes in ksh
I'm trying to get the file of the current date with the following command in HP-UX Unix:
$ ls -lrt ABC.LOG* |grep "`date +"%b %d"`"
But, it's giving me the error:
ksh: : cannot execute
grep: can't ...