compare dats in the shell script.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting compare dats in the shell script.
# 1  
Old 07-08-2009
compare dats in the shell script.

grep "HP_nv6005ud" mail_log.log | awk '{print $2}' >raju.log
if [ $? -eq 0 ]
then
grep "$testdate" raju.log
if [ "$ydate == $testdate" ]


Hi in the above script $2 gives rge today date. and $ydate is yesterdays date.
not in the if condition i need to compare both the dates.

Please help me in this.

Thanks in advance
Raju
# 2  
Old 07-08-2009
whats the format of date??
# 3  
Old 07-08-2009
Hi,

if [ "$ydate == $testdate" ]

if you use like this you will get the output.

if [ "$ydate" = "$testdate" ]
# 4  
Old 07-09-2009
date format will be 07/09/2009

---------- Post updated at 01:40 AM ---------- Previous update was at 01:37 AM ----------

i tried this its not working.
pleae tell me the other way
# 5  
Old 07-09-2009
A=07/09/2009
B=07/09/2009

if [ $A -eq $B ];then
echo "Hello\n";
fi
# 6  
Old 07-09-2009
Hi Thanks for your reply. now i am able to compare the dates.
But now i am trying to find the date less than one date. how to achive that.

Thanks in advance
# 7  
Old 07-09-2009
Do you want to find the previous date?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with shell script to compare values between servers

Hi I am a beginner in UNIX and shell scripting and i have a requirement as stated below, requirement Login to a unix server 1 1. connect to a database mysql -uUsername -pPassword 2. Select a Schema : "Use Schemaname1" 3. query for a particular record ... (2 Replies)
Discussion started by: Hamdul
2 Replies

2. Shell Programming and Scripting

Compare two files using shell script

Hi i want to compare two files and i need the o/p of only difference here the files file1 achilles aedxbepo aedxbwdm01 aedxbwdm02 albedo amarice ambrister anakin anton argon artephius asgard avatar aymara (10 Replies)
Discussion started by: venikathir
10 Replies

3. Shell Programming and Scripting

Shell script to compare two files

I have two files; file A and file B. I need all the entries of file A to be compared with file B line by line. If the entry exists on file B, then save those on file C; if no then save it on file D Note :- all the columns of the lines of file A need to be compared, except the last two columns... (8 Replies)
Discussion started by: ajiwww
8 Replies

4. Shell Programming and Scripting

Shell Script to Compare Two Files

I have a directory with about 6 files that we receive regularly. these 6 files contain information for 3 different units, 2 for each unit. files related to a specific unit are named similarly with a change in number at the end of the file. the numbers should be sequential. for each grouping of... (3 Replies)
Discussion started by: scriptman237
3 Replies

5. Shell Programming and Scripting

how to compare two lines using shell script?

how to compare two lines using shell script? (1 Reply)
Discussion started by: suman_dba1
1 Replies

6. Shell Programming and Scripting

String compare in shell script

Iam trying to compare the string in if else... but some how its not working following is the code On executing the above one its giving a error message ': bad number' in the above parameter l & k are numbers and dbfiles and patchefiles are array If i do echo ift working fine ... (2 Replies)
Discussion started by: kiranlalka
2 Replies

7. UNIX and Linux Applications

How to compare two files using shell script

hi experts please help me to compare two files which are in different directory file1<file will be master file> (/home/rev/mas.txt} ex x1 x2 file2 <will be in different folder> (/home/rev/per/.....) ex x3 x4 the filesinside per folder i need to compare with master file... (1 Reply)
Discussion started by: revenna
1 Replies

8. Shell Programming and Scripting

compare two tables using shell script

Hi, I want to compare two tables fieldwise using shell script. Can anyone help me regarding the same. The approach which i tried is to first move the two tables in simple txt file where each field is now seperated by space. But i can't retrive each field with "space" as a seperator b'coz there... (1 Reply)
Discussion started by: dtidke
1 Replies

9. Shell Programming and Scripting

How to compare the dates in shell script

Hi How to compare created or modified date of two files help needed thanks Vajiramani :) (9 Replies)
Discussion started by: vaji
9 Replies

10. Shell Programming and Scripting

shell script cant recognize if else compare

hi I face the problem the if else statement dint return correct result for me my script as below: #!/bin/ksh sqlplus -s /nolog <<EOF connect databaseuser/password column num new_value num format 9999 set head off select count(*) num from table1; exit num EOF if ; then echo "$?"... (6 Replies)
Discussion started by: jaseloh
6 Replies
Login or Register to Ask a Question