can't TEST multiple arguments for a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting can't TEST multiple arguments for a file
# 1  
Old 11-22-2005
can't TEST multiple arguments for a file

Hi,
I'm new to scripting and teaching myself how to code. Using Korn, I coded this one return "True" if a file is executable and it's not empty. However, each time I pass a file that is 777 which contains data, the script returns "false".

if [ -x -a ! -s "$1" ]
then
echo "true"
else
echo "false"

fi

By the way..
I was successful using AND when validating strings instead of a file

What am I missing?
# 2  
Old 11-22-2005
I think you want:

Code:
if  [[ -x  "$1" && -s "$1" ]] ; then
    echo "true"
else
    echo "false"
fi

# 3  
Old 11-22-2005
Makes sense to me and works fine.

Thank you, Jim!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Hit multiple URL from a text file and store result in other test file

Hi, I have a problem where i have to hit multiple URL that are stored in a text file (input.txt) and save their output in different text file (output.txt) somewhat like : cat input.txt http://192.168.21.20:8080/PPUPS/international?NUmber=917875446856... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

2. Shell Programming and Scripting

Multiple runtime arguments

I am passing 3 runtime arguments to a shell script $path crtl1 crtl2 the crtl files contains data(filename|date|count) filename.txt|02/05/2010|10 The path contains the original data file,the code should fetch (filename|date|count) from original data file and it should match... (7 Replies)
Discussion started by: Prashanth B
7 Replies

3. Shell Programming and Scripting

Multiple arguments to read

I am developing a script where 3 other scripts are included. This is a graph related script. COMPLETE IDEA: -There are 3 different graph scripts. I would like to create a master graph with all 3 in one. -User chooses the type of graph -User is asked to enter the required auguments (... (7 Replies)
Discussion started by: newkid.7955
7 Replies

4. UNIX for Dummies Questions & Answers

redirecting arguments in a script to multiple lines in a .txt file

Ok hope my vocab is right here, i'm trying to write multiple sets of arguments to another file for example: I have a script that accepts four arguments and sends them to a another file $write.sh it then out in so the file receiver.txt would contain this: it then out in what... (2 Replies)
Discussion started by: austing5
2 Replies

5. UNIX for Dummies Questions & Answers

To pass multiple arguments from file in to an sql query

Hi all , I want to pass contents from a file say f1 as arguments to a sql query which has In statement using a script example select * from table_1 where login in ( `cat f1`) ; will this work or is there any other way to do it. (1 Reply)
Discussion started by: zozoo
1 Replies

6. Shell Programming and Scripting

using switch on multiple arguments

I have a switch statement, and I want to have two options performing the same thing. For example, if $opt matches "-fb" or "--fbase", I want to perform the same operation. How can I include various matches in "case" ? switch ($opt) case "-T": set Atpath = $par set opt_tpath =... (8 Replies)
Discussion started by: kristinu
8 Replies

7. Shell Programming and Scripting

Test - too many arguments

How do I prevent the message "too many arguments" to appear when using this script? name="one two three four five six seven" if test $name="" then echo "Empty variable" else echo "Value assigned" fi output: bash: test: too many arguments Value assigned (2 Replies)
Discussion started by: locoroco
2 Replies

8. Shell Programming and Scripting

using multiple arguments in my script

hi all i am creating a script to ping hosts and then do a nslookup. So what needs to happen is that i type the script name with an argument eg: zong (script name) 172.x.x.x (IP) at the moment i have got it to take on argument, but idealy i would like it to take more than 1 argument. can you... (1 Reply)
Discussion started by: brian112
1 Replies

9. Shell Programming and Scripting

Run perl script with multiple file arguments

Hello everyone, I have two types of files in a directory: *.txt *.info I have a perl script that uses these two files as arguments, and produces a result file: perl myScript.pl abc.txt abc.xml How can I run this script (in a "for" loop , looping through both types of files)... (4 Replies)
Discussion started by: ad23
4 Replies

10. Shell Programming and Scripting

Can not test many arguments

I'm writing a shell script with bash ver 2.05b in linux. My script has a test with 5 arguments like this: until do .....(some codes) done but it raise an error: [: too many arguments I tried some ways but not ok. Could you give a way to work around this. Thanks... (4 Replies)
Discussion started by: baton
4 Replies
Login or Register to Ask a Question