date cmp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting date cmp
# 1  
Old 05-05-2009
date cmp

Please don't count this as a similar post.....I got the ftp part working....I am stuck how to find the files between two dates.
I have 5 files
filename.20090505.txt
filename.20090504.txt
filename.20090503.txt
filename.20090502.txt
filename.20090501.txt
My load date is 20090501 and run date is 20090505. I have to retrieve the files in between filename.20090504.txt,filename.20090503.txt,filename.20090502.txt based on the dates on the filename.
Pls help me.
Thanks in advance.
# 2  
Old 05-05-2009
Code:
awk -F"." '$2 < 20090505 && $2 > 20090501'

# 3  
Old 05-05-2009
Thanks franklin.... but when I type ur command i am not getting anything....I am not so good please help also I forgot I need the run_date file too. i.e filename.20090505.txt,filename.20090504.txt,filename.20090503.txt,filename.20090502.txt
awk -F"." '$2 < 20090505 && $2 > 20090501'
Pls can u elaborate
Thanks again
# 4  
Old 05-05-2009
Can you post what you have so far so we can understand where the list of filenames is coming from?

franklin52 example would process the vertical list of filenames in you first post either from a pipe or from a file.
e.g. from a file called my_list_of_files :

Code:
awk -F"." '$2 < 20090505 && $2 > 20090501' my_list_of_files
filename.20090504.txt
filename.20090503.txt
filename.20090502.txt

With ftp only it's probably going to be a three stage process?
1) Get a directory listing of the remote server directory and store it in a file on the local server.
2) Process the stored list to eliminate files which we have fetched already.
3) Fetch the files and record which ones have been processed.
# 5  
Old 05-05-2009
looks like this is perfect but can u plz tell me how to create the "my_list_of_files"

I am sorry to bother....
# 6  
Old 05-06-2009
Quote:
Originally Posted by RubinPat
looks like this is perfect but can u plz tell me how to create the "my_list_of_files"

I am sorry to bother....
You can get the file list with ls:

Code:
ls filename*.txt >  my_list_of_files
awk -F"." '$2 < 20090505 && $2 > 20090501' my_list_of_files

or without a file list:

Code:
ls filename*.txt | awk -F"." '$2 < 20090505 && $2 > 20090501'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies

2. Shell Programming and Scripting

Syntax Error while using CMP function

Hi All, I am getting a syntax error message while trying to compare 2 files using the compare function (LINUX) command substitution: line 79: syntax error near unexpected token `(' command substitution: line 79: `cmp -s <(tr , \n < $COMMON_TMP/nt_per_gs.done | sort) <(tr , \n <... (5 Replies)
Discussion started by: dsfreddie
5 Replies

3. Shell Programming and Scripting

Converting a date to friday date and finding Min/Max date

Dear all, I have 2 questions. I have a file with many rows which has date of the format YYYYMMDD. 1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too. 2. After converting the date to... (10 Replies)
Discussion started by: 2001.arun
10 Replies

4. Shell Programming and Scripting

How to compare files in two folders using cmp?

i recently copied 400GB of data from a NTFS drive to a ext4 drive. I want to verify that the data is 100% identical to the original. I wanted to use cmp but it only does two files. The directory that was copied contains many subdirectories and all sorts of files (not just text). So I guess... (5 Replies)
Discussion started by: fuzzylogic25
5 Replies

5. Solaris

cmp file

Dear all, for i in <List of Filename> FILENAME=`echo $i` do cp -p $FILENAME /temp /bin/cmp $FILENAME /temp/$FILENAME done I am planning to do something like this on a daily basis, so i want to ask that, if the comparison on the files encounter error, ... (2 Replies)
Discussion started by: beginningDBA
2 Replies

6. Shell Programming and Scripting

Issue in comparing (cmp) two files

Hi All, I have to compare set of files so I created a case statement with the option to give more than one file to compare. The Problem now i am facing is, if I compare the files directly, from prompt or just using the script only for a particular file then It's saying No difference, but If I... (4 Replies)
Discussion started by: Sudhar
4 Replies

7. Shell Programming and Scripting

CMP two files with slight difference and return code

I am comparing two files which are identical except for the timestamp which is incorporated within the otherwise same 372 bytes. I am using the command: cmp -s $Todays_file $Yesterdays_file -i 372 When I run the command without the -i 372 it shows the difference i.e. the timestamp.... (5 Replies)
Discussion started by: gugs
5 Replies

8. UNIX for Dummies Questions & Answers

cmp 2 variables

Hi I have two variables contining a set of near identical lines, i'd like to list the lines that differ? Prefereably i'd like not to save the variables into a file first. i.e var1 tag:val1 tag:val2 tag:val3 var2 tag:val1 tag:val4 tag:val3 i'd like the result to print out... (2 Replies)
Discussion started by: nickrick
2 Replies

9. Shell Programming and Scripting

cmp, diff need options

Hi, I am using diff filename1 filename2, as these files are of huge size,I want to know the count(n) no. of different records to be displayed on the terminal. I do not want the contents of file i mean different lines to be displayed. Cheers Kunal. (0 Replies)
Discussion started by: niceboykunal123
0 Replies
Login or Register to Ask a Question