On comparing two number getting error,not able to rectify it pplease help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting On comparing two number getting error,not able to rectify it pplease help
# 1  
Old 06-24-2007
On comparing two number getting error,not able to rectify it pplease help

Code:
temp=`cat /gcdm/prd/rawdata/LCDM_FR_CCF_00003_D_CARM | head -1 | cut -c 19-27` 
temp= `expr $temp - 1`
for file in `ls  /gcdm/prd/archive*/carm/LCDM_FR_CCF_00003_D_CARM/*.gz` 
do 
seq_no=`gunzip -c $file | head -1 | cut -c 19-27` 
if [$temp -eq $seq_no] then
echo found;
fi
done

this is code I am using
getting this out put

Code:
show detail fo each line of exection been done
+ + cat /gcdm/prd/rawdata/LCDM_FR_CCF_00003_D_CARM
+ cut -c 19-27
+ head -1
temp=000000629
+ + expr 000000629 - 1
temp=628
+ ls /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-13:10:49.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-15:33:54.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-16:28:23.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-17:19:45.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-18:10:01.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-19:09:38.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070605-08:09:11.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070605-11:25:00.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070605-12:10:36.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070606-15:37:44.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070607-06:36:05.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070607-07:36:10.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070607-08:35:48.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070608-14:42:31.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070611-05:57:25.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070611-07:17:41.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070613-14:40:23.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070613-15:32:29.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070618-05:55:39.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070618-07:26:13.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070618-08:48:54.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070618-10:26:47.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070619-06:23:39.gz /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070619-20:27:40.gz
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-13:10:49.gz
+ head -1
seq_no=000000604
+ + expr 000000604 + 0
seq_no=604
+ [628 -eq 604]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-15:33:54.gz
+ head -1
seq_no=000000605
+ + expr 000000605 + 0
seq_no=605
+ [628 -eq 605]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-16:28:23.gz
+ head -1
seq_no=000000606
+ + expr 000000606 + 0
seq_no=606
+ [628 -eq 606]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-17:19:45.gz
+ head -1
seq_no=000000607
+ + expr 000000607 + 0
seq_no=607
+ [628 -eq 607]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-18:10:01.gz
+ head -1
seq_no=000000608
+ + expr 000000608 + 0
seq_no=608
+ [628 -eq 608]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070604-19:09:38.gz
+ head -1
seq_no=000000609
+ + expr 000000609 + 0
seq_no=609
+ [628 -eq 609]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070605-08:09:11.gz
+ head -1
seq_no=000000611
+ + expr 000000611 + 0
seq_no=611
+ [628 -eq 611]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070605-11:25:00.gz
+ head -1
seq_no=000000612
+ + expr 000000612 + 0
seq_no=612
+ [628 -eq 612]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070605-12:10:36.gz
+ head -1
seq_no=000000613
+ + expr 000000613 + 0
seq_no=613
+ [628 -eq 613]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070606-15:37:44.gz
+ cut -c 19-27
+ head -1
seq_no=000000614
+ + expr 000000614 + 0
seq_no=614
+ [628 -eq 614]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070607-06:36:05.gz
+ head -1
seq_no=000000615
+ + expr 000000615 + 0
seq_no=615
+ [628 -eq 615]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070607-07:36:10.gz
+ cut -c 19-27
+ head -1
seq_no=000000616
+ + expr 000000616 + 0
seq_no=616
+ [628 -eq 616]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070607-08:35:48.gz
+ head -1
seq_no=000000617
+ + expr 000000617 + 0
seq_no=617
+ [628 -eq 617]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070608-14:42:31.gz
+ head -1
seq_no=000000618
+ + expr 000000618 + 0
seq_no=618
+ [628 -eq 618]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070611-05:57:25.gz
+ head -1
seq_no=000000619
+ + expr 000000619 + 0
seq_no=619
+ [628 -eq 619]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070611-07:17:41.gz
+ cut -c 19-27
+ head -1
seq_no=000000620
+ + expr 000000620 + 0
seq_no=620
+ [628 -eq 620]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070613-14:40:23.gz
+ head -1
seq_no=000000621
+ + expr 000000621 + 0
seq_no=621
+ [628 -eq 621]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070613-15:32:29.gz
+ head -1
seq_no=000000622
+ + expr 000000622 + 0
seq_no=622
+ [628 -eq 622]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070618-05:55:39.gz
+ head -1
seq_no=000000623
+ + expr 000000623 + 0
seq_no=623
+ [628 -eq 623]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070618-07:26:13.gz
+ head -1
seq_no=000000624
+ + expr 000000624 + 0
seq_no=624
+ [628 -eq 624]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070618-08:48:54.gz
+ cut -c 19-27
+ head -1
seq_no=000000625
+ + expr 000000625 + 0
seq_no=625
+ [628 -eq 625]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070618-10:26:47.gz
+ head -1
seq_no=000000626
+ + expr 000000626 + 0
seq_no=626
+ [628 -eq 626]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070619-06:23:39.gz
+ head -1
seq_no=000000627
+ + expr 000000627 + 0
seq_no=627
+ [628 -eq 627]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0
+ + cut -c 19-27
+ gunzip -c /gcdm/prd/archiveoff/carm/LCDM_FR_CCF_00003_D_CARM/LCDM_FR_CCF_00003_D_CARM-20070619-20:27:40.gz
+ head -1
seq_no=000000628
+ + expr 000000628 + 0
seq_no=628
+ [628 -eq 628]
seq_err.sh[7]: [628:  not found.
+ echo if status 0
if status 0


and running the script gives following out with out debugging option

seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
seq_err.sh[7]: [628:  not found.
if status 0
Please help me in removing the error in out put...

# 2  
Old 06-24-2007
Missing spaces in test and; before then:
Code:
temp=`cat /gcdm/prd/rawdata/LCDM_FR_CCF_00003_D_CARM | head -1 | cut -c 19-27` 
temp= `expr $temp - 1`
for file in `ls /gcdm/prd/archive*/carm/LCDM_FR_CCF_00003_D_CARM/*.gz` 
do 
   seq_no=`gunzip -c $file | head -1 | cut -c 19-27` 
   if [ $temp -eq $seq_no ] ;then
      echo found
   fi
done

# 3  
Old 06-25-2007
Bug

Thanks for finding out Bug,its working fine...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing floating number and replace the smaller one with awk?

Hi guys, I tried to write a script for replacing some number in a bunch of files. However, I failed because my limited bash scripting knowledge. Here I will explain the expected function: I have many data files need to be processed. Here shows one part of a file as an example: a list with... (7 Replies)
Discussion started by: liuzhencc
7 Replies

2. Shell Programming and Scripting

Error while comparing dates

Hi I am failing to write a script which compares a list of dates in a file with today's date. OS: Solaris 10 I have a file which has server names & dates, i need to compare the date in this file with today's date, if it is less than today it should print the server name. code i tried is ... (3 Replies)
Discussion started by: nanz143
3 Replies

3. UNIX for Dummies Questions & Answers

Comparing a number in a text file with a specific value

My project is to get a temperature reading from a refridgerator every 2 minutes and check to see if the door has been left open. I don't yet have the mastery of Linux, being a complete noob, but I reckon I need a text file with the latest temperature reading in it. This I've managed to do by... (2 Replies)
Discussion started by: Fitch
2 Replies

4. Shell Programming and Scripting

how to avoid 'unexpected operator' error when comparing 2 strings

this is my file: #!/bin/sh a=`cat /home/$USER/Desktop/lol` c=`cat /home/$USER/Desktop/lol1` if ; then echo "$a = $c" else echo "They are not equal" fi The lol file contains 1aa and the lol1 file contains 1aa as well. Unfortunately the output is Even when I put -eq instead of == I get ... (9 Replies)
Discussion started by: hakermania
9 Replies

5. UNIX for Dummies Questions & Answers

Comparing two files and count number of lines that match

Hello all, I always found help for my problems using the search option, but this time my request is too specific. I have two files that I want to compare. File1 is the index and File2 contains the data: File1: chr1 protein_coding exon 500 600 . + . gene_id "20532";... (0 Replies)
Discussion started by: DerSeb
0 Replies

6. Shell Programming and Scripting

Comparing String with Number variables

I have two variables and want to perform some functions after comparison $cat file1 14.abcde a=`cut -f 1 -d "." file1 b=15 if then .... fi but i got an error message says that unary operator expected and i think its because of $a is a string and trying to compare with... (3 Replies)
Discussion started by: bonosungho
3 Replies

7. Linux

how to rectify the MS Office problem

Dear forum members, I was configured smb ldap in fedora core 6, past 1 year its running nice with out any problem. but last one week I can't able to save microsoft office application(excel) in server. server having a sufficient memory(2Gb RAM). this problem only for ms application. how can i... (4 Replies)
Discussion started by: erbalamurugan
4 Replies

8. UNIX for Advanced & Expert Users

Script error.. for comparing 2 files!

Hi I am using the below script to compare two files.. i am getting error as mentioned below: #!/bin/sh # Script to find the difference between 2 files # Remember the old file file1 should always be the first argument. Else, the logic would reverse. # diff.sh <old file> <new file> if ] ;... (4 Replies)
Discussion started by: gkrishnag
4 Replies

9. Shell Programming and Scripting

please rectify my problem

Dear Friends, I have two data file containing 4 coloums. my first file has data like this ex: file1: 2.56 66.82 *** 2.56 66.82 *** 2.54 66.84 *** 2.54 66.84 *** 2.51 66.84 *** 2.51 66.84 *** 2.51 ... (8 Replies)
Discussion started by: rajan_ka1
8 Replies

10. Shell Programming and Scripting

comparing float with int / number

Hi all, I'm looking to modify a script to check disk space usage. Here is the code at the moment: # # The control file, MONITOR_DISK_SPACE, must be in the format ... Drive:;threshold_percentage # eg. # C:;95 # D:;98 # E:;90 # # For each line in the control file (MONITOR_DISK_SPACE)... (2 Replies)
Discussion started by: lelliott
2 Replies
Login or Register to Ask a Question