Sponsored Content
Top Forums Shell Programming and Scripting can't TEST multiple arguments for a file Post 90430 by jim mcnamara on Tuesday 22nd of November 2005 03:08:41 PM
Old 11-22-2005
I think you want:

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

 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.10 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 07:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy