07-19-2005
I often use the double [[ ]] to get the ksh internal tests.
if [[ -f $File ]]
then
print "yes"
else
print "no"
fi
You could use -L to test links, or -n just to see if $File is set.
a short notation is
[[ -f $File ]] && print "yes" || print "no"
Als nice is:
[[ ! -f $File ]] && print "no file found" && return 1
(abort script, returns with non-zero exit code)
6 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Anyone know the code to test for bad numbers?
For example in ksh...
Want the user to input an integer, but they input characters.
read number
while (number = letter)
read number //until valid number is inputted
thx for any help!! :confused: (3 Replies)
Discussion started by: gsxpower
3 Replies
2. Shell Programming and Scripting
Hi all this is simple but bad day for me nothing work out ..
Problem is that I wan to check the argument passed to my script and accordignly exit or setup ENV variable
I have a script name src_cpcp_preproc.sh
i want to pass 2 argumet from command line argumet and check it in the script... (13 Replies)
Discussion started by: jambesh
13 Replies
3. Shell Programming and Scripting
This is the code:
while test 1 -eq 1
do
read a
$a
if test $a = stop
then
break
fi
done
I read a command on every loop an execute it.
I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test.
For example echo hello.
Now the... (1 Reply)
Discussion started by: Max89
1 Replies
4. Shell Programming and Scripting
How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies
5. Shell Programming and Scripting
Why I get bad replace when using eval?
$ map0=( "0" "0000" "0")
$ i=0
$ eval echo \${map$i}
0000
$ a=`eval echo \${map$i}` !!!error happens!!!
bash: ${map$i}: bad substitution
How to resolve it ?
Thanks! (5 Replies)
Discussion started by: 915086731
5 Replies
6. Shell Programming and Scripting
Hi,
I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
Discussion started by: royalibrahim
5 Replies