Likenota
Likenota

Reputation: 97

Bash shell how do i format Date to be lower case for month?

The following command makes the date Sept18_1024x728.jpg how do i make it so it will format it with sept18_1024x728.jpg instead?

           cp "$p" "./FOLDER/$(date +%b%d).$SIZE.jpg"

Upvotes: 2

Views: 2449

Answers (2)

rici
rici

Reputation: 241881

You can pipe through tr to translate upper to lowercase:

cp "$p" "./FOLDER/$(date +%b%d | tr A-Z a-z).$SIZE.jpg"

Or the locale-aware version:

cp "$p" "./FOLDER/$(date +%b%d | tr '[:upper:]' '[:lower:]').$SIZE.jpg"

Upvotes: 2

karakfa
karakfa

Reputation: 67527

bash to lower case function...

$ d=$(date +%b%d); cp "$p" "./FOLDER/${d,,}.$SIZE.jpg"

NB. in this particular case ${d,} will also work, since only the first char needs to be converted.

Upvotes: 1

Related Questions