LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-10-2005, 03:33 PM   #1
Ratclaws
Member
 
Registered: Sep 2001
Location: New York
Distribution: Slackware 8
Posts: 102

Rep: Reputation: 16
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.
 
Old 12-10-2005, 04:45 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 06:09 PM
What is the diff between / and // stardotstar Linux - Newbie 1 09-30-2004 01:02 AM
Dual Boot diff Hard Disk diff OS on Suse 9.1 wilhem Linux - Newbie 1 08-13-2004 06:06 PM
PHP Trouble Syntax Gerardoj Programming 2 03-30-2004 09:10 PM
What a Diff! perry General 0 12-05-2003 07:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration