0

how to find the files in a directory with Prefix__date_030000_Suffix

here Prefix is the Actual file name and format of the date is date +%Y%m%d and Suffix is the '.txt' and the 030000 number will vary for each file.

My requirement is to find the files that has a prefix and suffix with the provided in the date format.

for example:--the file name is like ABC_XYZ_40001_20150119_030000_1.txt here ABC_XYZ_40001 is the Prefix 20150119 is the provided date 1.txt is the suffix. Using the ls grep cat and sed to get the file name, is there any way that we can achive with FIND command.

  • Your question is not clear. Are you looking for files for a specific date or any date? It would help if you gave examples of file names that should match and file names that should not match. – Gilles Feb 26 '15 at 19:57
1

You can use something like this :

ls *_$(date +%Y%m%d)_*.txt

You don't even need cat, grep, etc...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.