I have a bunch of files in the following format:
2014-11-19.8.ext
2014-11-26.1.ext
2014-11-26.2.blah.ext
2014-11-26_3.ext
2014-11-26.4.stuff_here.ext
2014-12-03.1. could be anything.ext
2014-12-032b.ext
2014-11-26 613 adva.ext
My goal is to iterate over the entire list of files and to take the date formatting from YYYY-MM-DD
and store that in a variable in the format of YYYYMMDD
for further processing (in my case It's going to be pushed into a touch
command).
So normally I would match against this regular expression: (\d{4})-(\d{2})-(\d{2}).*
And then use $1$2$3
to get my desired pattern, however I'm not sure how to do this in bash
/ zsh
.
How can this be done within a shell script as such?
YYYY
andMM
, but then you just grab the rest with${f:8}
, when I would rather just grabDD
and discard.*
(everything afterDD
).