On 19Aug2013 15:15, Mark Haney <[email protected]> wrote:
| Let me try again. I want to copy a file with a filename like
| 2013-August-18--1123.zip to another folder. However, because the last 4
| digits of the filename won't always be the same, I want to be able to
| search in a bash script for '2013-August-18--*.zip'. I.e. match all files
| with '2013-August-18--' in the filename. From a console I can do this by:
|
| ls 2013-August-18--*.zip
|
| How can I do that in a bash script. I can probably use find, but this
| seems much simpler and/or quicker than finding one file.
Your console is almost certainly running a bash already. If it works there,
it should work in a script.
Look (untested):
datepart=`date +%Y-%B-%d`
for match in "$datepart--"*.zip
do
[ -f "$match" ] || continue # if no match we get a bare "*"
... do stuff with the file "$match" ...
done
What about the above doesn't work for you, or isn't what you want?
Cheers,
--
Cameron Simpson <[email protected]>
--
users mailing list
[email protected]
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org