if statement [message #97833] |
Sat, 22 February 2003 01:48 |
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 |
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 |wc -l x|cut -b7-8`
integer sec_count=`wc -l $sec_file |wc -l y|cut -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
|
|
|