LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   sh / diff syntax trouble (https://www.linuxquestions.org/questions/programming-9/sh-diff-syntax-trouble-391349/)

Ratclaws 12-10-2005 03:33 PM

sh / diff syntax trouble
 
i can get my command to run from the command line, but it breaks when i put it in an sh if loop

from the command line
Code:

md5 -q /file | diff --brief /file.md5 -
(the "-" is supposed to take input from stdin)

in the script i have this
Code:

if [[ md5 -q $LOG | diff --brief $SUM - ]]; then
    echo;echo "They are new!";echo
else
    echo;echo "do nothing.";echo
fi

but this is the output that i get:
Code:

[[: not found
diff: extra operand
diff: Try `diff --help' for more information.

do nothing.


acid_kewpie 12-10-2005 04:45 PM

well that's just not right in any way.. did you read any scripting howto's, like the bash advanced scripting howto at tldp.org? firstly [[ is not a command, the synonym for test is just [ closed with ] also wrap the string there inside the test with $(md5...SUM -) as that also totally breaks the syntax:

if [ $(md5 -q $LOG | diff --brief $SUM -) ];

no idea if what you're actually trying to evaulte will make sense within the context of a test statement though.


All times are GMT -5. The time now is 07:35 PM.