Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2012-06-20T17:14:43Z by grumpy57
grumpy57
grumpy57
2 Posts
ACCEPTED ANSWER

Pinned topic ! in if statements

‏2012-06-19T20:59:43Z |
What is the ! mean in an cron scripts I have seen it in if statements, echo statements,

if [[ ! -a $file || ! -s $file ]]

or

tbasic <<!EOF! >> $TXTFILE

or

SDS_JOBS=`cat $data/start.dat | grep -v "!" | wc -l`
Updated on 2012-06-20T17:14:43Z at 2012-06-20T17:14:43Z by grumpy57
  • haubi
    haubi
    37 Posts
    ACCEPTED ANSWER

    Re: ! in if statements

    ‏2012-06-20T06:44:08Z  in response to grumpy57
    There is no such thing like "cron scripts", they are pure (korn-)shell scripts, eventually started by cron.

    For the syntax of korn-shell scripts, try "man ksh93".

    > if [[ ! -a $file || ! -s $file ]]

    Here it is the "not" operator, to be read as "if not exists $file or not exists-and-has-size-greater-than-zero $file".

    > tbasic <<!EOF! >> $TXTFILE

    Here it doesn't have any special meaning, it is part of the token "!EOF!" defined to mark the end of inlined text used as stdin for 'tbasic' command.

    > SDS_JOBS=`cat $data/start.dat | grep -v "!" | wc -l`

    Again no special meaning: SDS_JOBS contains the numer of lines in start.dat not containing "!".

    HTH,
    /haubi/
  • grumpy57
    grumpy57
    2 Posts
    ACCEPTED ANSWER

    Re: ! in if statements

    ‏2012-06-20T17:14:43Z  in response to grumpy57
    Thanks for the update