LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-27-2010, 11:25 PM   #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-27-2010, 11:50 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
What is the error?
 
Old 07-27-2010, 11:54 PM   #3
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
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, 02: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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:13 AM.

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