LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to search for a file that has the date in the filename nomenclature (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-search-for-a-file-that-has-the-date-in-the-filename-nomenclature-681434/)

iherrejon 11-05-2008 11:39 PM

How to search for a file that has the date in the filename nomenclature
 
Hi all,

I am new to unix/linux. I am seeking your assistance on know how to do a search for a file that has the date in the filename. The date obviously changes. Any help is greatly appreciated.

DYYMMDD.CUSA

I am lost :/

centos82 11-06-2008 12:38 AM

I would recommend the following:
find / -name DYYMMDD.CUSA 2>/dev/null

So if you were looking for a file with a date of Nov 6th 2008 you would do:

find / -name D081106.CUSE 2>/dev/null

john test 11-06-2008 09:42 AM

Might try locate:
Code:

$ locate 101107
/home/john/e_configs101107.tar.gz
/home/fred/e_configs101107.tar.gz
/etc/skel/e_configs101107.tar.gz

of course you have to know the date and format of the date in the filename.

iherrejon 11-06-2008 10:33 AM

Thank you for your reply centos62. However, the filename changes as the date changes.


Quote:

Originally Posted by centos82 (Post 3333127)
I would recommend the following:
find / -name DYYMMDD.CUSA 2>/dev/null

So if you were looking for a file with a date of Nov 6th 2008 you would do:

find / -name D081106.CUSE 2>/dev/null


Tinkster 11-06-2008 11:35 AM

Code:

find / -name D[0-9][0-9][0-9][0-9][0-9][0-9].CUSA
should do the trick?

Cheers,
Tink


P.S.: Please use proper quoting. TOFU sucks.

iherrejon 11-06-2008 11:00 PM

I apologize if I didn't explain myself properly. I need to have a script in place to automatically download a file that has the previous day date in the filename. I am sorry for the confusion that I generated.

DYYMMDD.CUSA

Thanks to everybody :)

centos82 11-06-2008 11:33 PM

I don't think your requirments have been fully stated yet. Will you always be downloading yesterdays file? Will the file always be located in the same directory?

If you provide some sort of pseudo code, then I'm sure someone here could provide the actual script code.

rohit_k 11-07-2008 12:26 AM

find / -name D`date --date="1 days ago" +%y%m%d`.CUSA

you can replace find with wget, scp

Rohit Kalsarpe


All times are GMT -5. The time now is 12:57 AM.