LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-28-2010, 12:25 AM   #1
arch12
LQ Newbie
 
Registered: Jul 2010
Posts: 5

Rep: Reputation: 0
syntax error for grep with if


#!/bin/ksh

Alarms= $(grep MAJOR /osp/3rdpty/JBOSS/jboss-eap-4.3/jboss-as/server/apcProfile/log/alarm.log* | tail | wc -l )

if [ "$(Alarms)" -eq 0 ]

then

echo " "

else

echo " $Alarms "

fi
 
Old 07-28-2010, 12:50 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,250

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
What is the error?
 
Old 07-28-2010, 12:54 AM   #3
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Are you sure it's not the if statement ?

Code:
if [ "$(Alarms)" -eq 0 ]
# this will try to run the command 'Alarms' and compare the return code with 0

Code:
if [ "${Alarms}" -eq 0 ]
# this will compare the value of the variable Alarms with 0
 
Old 07-28-2010, 03:40 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
case "$Alarms" in
 "0" ) echo "0" ;;
esac
 
  


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
[SOLVED] Syntax Grep and Cat ifeatu Programming 5 05-16-2010 01:17 AM
[SOLVED] grep syntax error? sl33p Linux - Newbie 3 05-23-2009 05:44 PM
Need a little help with grep syntax okos Linux - Software 2 01-26-2009 12:50 AM
grep script/syntax carriehoff Linux - Newbie 6 08-31-2006 02:13 PM
Grep syntax questions Phaethar Linux - General 4 04-11-2005 10:34 AM


All times are GMT -5. The time now is 04:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration