Re: BASH and wildcard expansion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19Aug2013 15:15, Mark Haney <mark.haney@xxxxxxxxx> 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 <cs@xxxxxxxxxx>
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
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




[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux