Home » Infrastructure » Unix » if statement
if statement [message #97833] Sat, 22 February 2003 01:48 Go to next message
Victoria
Messages: 152
Registered: July 2002
Senior Member
Hi,
I have one shell script ...in which i have written the following.

file_name1=source
file_name2=cpsource
count1=echo `cat ${file_name1} | wc -l`
count2=1
#if [[ `echo cat ${file_name1} | wc -l` -gt 1 ]]
if [[ $count1 -gt $count2 ]]
then
my statements
else
fi

Here i have 3 lines in the source file.I need to execute the staements which are inside the if statements...if the number of lines in the source file exceeds 1.
So i used the above if statement.But am getting the following error.pls help me...

rdcaio_local.sh[[13]]: 3: not found
rdcaio_local.sh[[16]]: test: argument expected
Thanks
~V~
Re: if statement [message #97843 is a reply to message #97833] Tue, 04 March 2003 00:51 Go to previous message
waris
Messages: 115
Registered: November 2001
Senior Member
Hi victoria,

Hope this gets u going...

#!/bin/ksh
first_file="/export/home/varish/x"
sec_file="/export/home/varish/y"
integer first_count=`wc -l $first_file &#124wc -l x&#124cut -b7-8`
integer sec_count=`wc -l $sec_file &#124wc -l y&#124cut -b7-8`
if [[ $first_count -gt $sec_count ]]
then
echo "x is having more lines"
else
echo "y is having more lines"
fi

cheers
waris
Previous Topic: Re: URGENT : Unix date format into Oracle date format
Next Topic: installation of oracle 7.3 on sco open release 5.06
Goto Forum:
  


Current Time: Tue Nov 26 11:01:58 CST 2024