fail on comparison

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting fail on comparison
# 1  
Old 08-15-2009
fail on comparison

Am having 2 files.

I have one data file.
before inserting in to the table am taking cout of the data file and store as data 1.

After insert in to the table and am taking the count from the table and store as data2.

If i try to compare those values

If [ $data1 = $data2]
  echo "data match"
  echo "data mismatch"

The issue is am having the same value in data 1 and data 2,but still am getting data mismatch error.

Is anything wrong in my code?

Please advice.

Last edited by Franklin52; 08-15-2009 at 06:40 PM.. Reason: Please use code tags!
# 2  
Old 08-15-2009
thats because the value of count that you are fetching from database may have some space.. can you post that query and settings(like set head off,set feedback off,set pages 0 etc)
# 3  
Old 08-15-2009
Originally Posted by bobprabhu
If [ $data1 = $data2 ]

if [ "$data1" = "$data2" ]

# 4  
Old 08-18-2009
i did the adviced changes ,still am getting the difference...Since the values on the data file are same.Smilie

---------- Post updated at 02:16 AM ---------- Previous update was at 02:16 AM ----------

Please any other over come this?
# 5  
Old 08-18-2009
before comparing data1 and data2 do this
echo "$data1"|cat -vet
echo "$data2"|cat -vet

and post the o/p
# 6  
Old 08-18-2009
Below is a better way to compare two numbers

If [ "$data1" -eq "$data2" ]


Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Fail to register

After inputted all required fields in registration page, the below message is shown and cannot go on. A required field called Custom Date & Time Formats is missing or has an invalid value. (2 Replies)
Discussion started by: Unregistered
2 Replies

2. Shell Programming and Scripting

Untar fail

Hi Team, I have a file named as follows: aaa.tar.gz Now I need to verify if the untar fails, then the script has to send a mail. In order to check this condition, I need a tar.gz file which is unable to untar it. Can anyone help me to create a file which I will be able to unzip successfully... (2 Replies)
Discussion started by: kmanivan82
2 Replies

3. Red Hat

System fail to boot

Hi im using centos 6.4 starting yesterday i have a strange issue that im unable to resolve. the system is booting to GRUB menu and the os is not starting. i tried to run a repair install and the message attached is what i get, what can cause this? thanks, (1 Reply)
Discussion started by: guy3145
1 Replies

4. Linux

Telnet fail

Hi, I try to telnet to server: # telnet 1521 Trying telnet: connect to address Connection refused telnet: Unable to connect to remote host: Connection refused iptables is off: # service iptables status Firewall is stopped. # And I have edit... (4 Replies)
Discussion started by: mehrdad68
4 Replies

5. Shell Programming and Scripting

Why does my test fail ??

Hello, I am stuck... i dunno why does my test fail... any idea ? #!/bin/bash dos2unix info.txt Distor=Distributeur LINE=$(cat info.txt | sed -n 1p) echo $LINE echo $Distor echo "" echo "123-$LINE-123" echo "123-$Distor-123" if ; then LINE2=$(cat info.txt | sed -n 2p) echo $Distor... (14 Replies)
Discussion started by: patx
14 Replies

6. Red Hat

webmin login fail

Hi all, I got error, when i logged with webmin. please show me the way how can i login with webmin (4 Replies)
Discussion started by: mastansaheb
4 Replies

7. AIX

en0 fail to up.

This is a LPAR that i created earlier. I want to set an IP address to en0 but it failed. Command: failed stdout: yes stderr: no Before command completion, additional instructions may appear below. en0 devdbm01 inet0 changed Method error (/usr/lib/methods/chgif): ... (8 Replies)
Discussion started by: wingcross
8 Replies

8. Shell Programming and Scripting

Rename fail

I've a lot of file with an hyphen on filename, so I use rename for remove him ad substitute with an underscore but it fails $ rename 's/\-/\_/' * Unknown option: _ Unknown option: i Unknown option: r Unknown option: e Unknown option: e Unknown option: _ Unknown option: g Unknown... (12 Replies)
Discussion started by: cv313x
12 Replies

9. Programming

Fail tail algorithm

I am currently working on code that simulates a file tail algorithm since the only way to retrieve the required information is from within a file, and this information needs to be retrieved in as close to real time as possible when the event enters the file. I cannot use system("tail <options>")... (6 Replies)
Discussion started by: foureightyeast
6 Replies

10. UNIX for Dummies Questions & Answers

Mail fail

I am using the shell script file to send mail by "mailx". I do this by cron job, there is no error found. But it is fail, any suggest to me? How can I resend it automatically? Is there any resend logic by using the mailx? (3 Replies)
Discussion started by: adela
3 Replies
Login or Register to Ask a Question