Solved

Linux - command if ($PARAM1 -gt 0 ); then or if [$PARAM1 -gt 0]; then - produce error

Posted on 2014-01-29
4
454 Views
Last Modified: 2014-01-29
Hi experts.
Line 14 is giving me error.


[oracle@hpescs1 /home/oracle/dba/scripts/ARCHIVES]# bash -vx verifica_archives.sh
ORACLE_HOME=/oracle/orabase/ora11g
+ ORACLE_HOME=/oracle/orabase/ora11g
export ORACLE_HOME
+ export ORACLE_HOME
ORACLE_SID=SCSD1
+ ORACLE_SID=SCSD1
export ORACLE_SID
+ export ORACLE_SID
PATH=/oracle/orabase/ora11g:/oracle/orabase/ora11g/bin:/oracle/orabase/ora11g/OPatch:/oracle/orabase/ora11g/lib:/usr/lib:/usr/openv/netbackup/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/sbin::/usr/ccs/bin
+ PATH=/oracle/orabase/ora11g:/oracle/orabase/ora11g/bin:/oracle/orabase/ora11g/OPatch:/oracle/orabase/ora11g/lib:/usr/lib:/usr/openv/netbackup/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/sbin::/usr/ccs/bin
export PATH
+ export PATH
sqlplus /nolog<<EOF
connect /as sysdba
@/home/oracle/dba/scripts/ARCHIVES/verifica.sql
EOF
+ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jan 29 10:31:19 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> Connected.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
awk '{if ($1 < 400) print "archive"} ' /home/oracle/dba/scripts/ARCHIVES/textfile.lst > /home/oracle/dba/scripts/ARCHIVES/archives_space_tight
+ awk '{if ($1 < 400) print "archive"} ' /home/oracle/dba/scripts/ARCHIVES/textfile.lst
log=/home/oracle/dba/scripts/ARCHIVES/archives_space_tight
+ log=/home/oracle/dba/scripts/ARCHIVES/archives_space_tight
PARAM1=$(wc -l < /home/oracle/dba/scripts/ARCHIVES/archives_space_tight)
wc -l < /home/oracle/dba/scripts/ARCHIVES/archives_space_tight
++ wc -l
+ PARAM1=1
if ($PARAM1 -gt 0 ); then
/home/oracle/dba/scripts/ARCHIVES/RMAN_ARCH_DELETE.sh
fi
+ 1 -gt 0
verifica_archives.sh: line 14: 1: command not found
0
Comment
Question by:LindaC
  • 2
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
ID: 39817812
Try
if  [ $PARAM1 -gt 0 ]; then

Open in new window


or

if  [[ $PARAM1  > 0  ]]; then

Open in new window


or

if (( PARAM1 > 0 )); then

Open in new window


Please notice spaces after [ and before ]
0
 
LVL 8

Author Closing Comment

by:LindaC
ID: 39817821
Thank you!
0
 
LVL 31

Expert Comment

by:farzanj
ID: 39817825
You are welcome.

Also note that $ in the last expression is optional
0
 
LVL 8

Author Comment

by:LindaC
ID: 39817827
Thank you.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now