file name format is month_day_YYYY(lowercase month) how do I find it with a date command?(date only gives capital Month)

LordJezo

Banned
May 16, 2001
8,140
1
0
For example the file name is:

file_sep_08_2003.gz

if I do a date command in that format I will get back

Sep_08_2003.

How would I be able to write anything to find the file based on the day if all the date command returns is the month with a capital first letter??

date +_%b_%d_%Y will return _Sep_23_2003 but that wont do me good since unix/ftp is case sensitive..

Thanks if you can help.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You could run the output through sed to transform all the letters to lowercase.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
with sed:

date +_%b_%d_%Y | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'

with tr:

date +_%b_%d_%Y | tr 'A-Z' 'a-z'

I thought you could use the regular expressions with sed like I did with tr, but for some reason it just wouldn't work. Either way, it's your choice.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Yeah that's odd, I would have expected sed -e 'y/A-Z/a-z/' to work too. Though when sed regexps aren't enough, you can always whip out perl. :evil: I.e. pipe through perl -pe 'y/A-Z/a-z/'. But I think it's generally better to use small tools like tr and cut, instead of using the 400lb gorillas sed and awk, or the 5000lb gorilla perl ;)