Looking for a better way to do this


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Looking for a better way to do this
# 1  
Old 01-01-2019
Looking for a better way to do this

I have a script that is searching for a file with todays date as part of the file name.

This works great with a 2 digit day but here is the problem. Those first 9 days of the month .
Code:
ls -l MMDVM_Bridge-"$(date -d "0 day" "+%Y-%m-%-d")".log 
ls: cannot access 'MMDVM_Bridge-2019-01-1.log': No such file or directory

it exists as 2019-01-01

Code:
root@442400Spotsy-pi:/var/log/dvswitch# ls -l MMDVM_Bridge-2019*                             
-rw-r--r-- 1 root root 358 Jan  1 09:12 MMDVM_Bridge-2019-01-01.log

Any thoughts ?



Mike

Last edited by vbe; 01-01-2019 at 11:16 AM.. Reason: code tags
# 2  
Old 01-01-2019
Code:
date -d "0 day" "+%Y-%m-%-d"

should be
Code:
date -d "0 day" "+%Y-%m-%d"

This User Gave Thanks to vbe For This Post:
# 3  
Old 01-01-2019
So damn simple, Augh... Thank you
# 4  
Old 01-01-2019
Sometimes 4 eyes help Smilie
This User Gave Thanks to vbe For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question