Sponsored Content
Full Discussion: Can not test many arguments
Top Forums Shell Programming and Scripting Can not test many arguments Post 90097 by vino on Friday 18th of November 2005 07:12:55 AM
Old 11-18-2005
You might want to check the man pages. See the following in bold.
From man ksh

Code:
       [[ expression ]]
              Similar to the test and [ ... ] commands (described later), with
              the following exceptions:
                ·    Field splitting and file name  generation  are  not  per-
                     formed on arguments.
                ·    The  -a  (and) and -o (or) operators are replaced with &&
                     and ||, respectively.
                ·    Operators (e.g., -f, =, !, etc.) must be unquoted.
                ·    The second operand of != and = expressions  are  patterns
                     (e.g., the comparison in
                                        [[ foobar = f*r ]]
                     succeeds).
                ·    There  are two additional binary operators: < and > which
                     return true if their first string operand is  less  than,
                     or  greater  than,  their  second string operand, respec-
                     tively.
                ·    The single argument form of  test,  which  tests  if  the
                     argument  has  non-zero  length,  is not valid - explicit
                     operators must be always be used, e.g., instead of
                                              [ str ]
                     use
                                           [[ -n str ]]
                ·    Parameter, command and arithmetic substitutions are  per-
                     formed  as  expressions are evaluated and lazy expression
                     evaluation is used for the &&  and  ||  operators.   This
                     means that in the statement
                                  [[ -r foo && $(< foo) = b*r ]]
                     the  $(<  foo)  is  evaluated if and only if the file foo
                     exists and is readable.

 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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 then echo "true" else echo... (2 Replies)
Discussion started by: cruiser
2 Replies

2. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

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

3. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 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

grep with two arguments to arguments to surch for

Hello, is it possible to give grep two documents to surche for? like grep "test" /home/one.txt AND /home/two.txt ? thanks (1 Reply)
Discussion started by: Cybertron
1 Replies

6. Shell Programming and Scripting

Prefixing test case methods with letter 'test'

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
let(1)								   User Commands							    let(1)

NAME
let - shell built-in function to evaluate one or more arithmetic expressions SYNOPSIS
ksh let arg... ksh93 let [expr...] DESCRIPTION
ksh Each arg is a separate arithmetic expression to be evaluated. ksh93 let evaluates each expr in the current shell environment as an arithmetic expression using ANSI C syntax. Variables names are shell vari- ables and they are recursively evaluated as arithmetic expressions to get numerical values. let has been made obsolete by the ((...)) syn- tax of ksh93(1) which does not require quoting of the operators to pass them as command arguments. EXIT STATUS
ksh ksh returns the following exit values: 0 The value of the last expression is non-zero. 1 The value of the last expression is zero. ksh93 ksh93 returns the following exit values: 0 The last expr evaluates to a non-zero value. >0 The last expr evaluates to 0 or an error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
ksh(1), ksh93(1), set(1), typeset(1), attributes(5) SunOS 5.11 2 Nov 2007 let(1)
All times are GMT -4. The time now is 11:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy