Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: checking for file existence when I don't know the exact name



2011-10-24, 09:16(-04), TJ Luoma:
> I want to check to see if a file exists that matches this pattern:
>
> OmniFocus-XXXXX.omnilicense
>
> where XXXXX is some set of numbers of an unknown length.
>
> I've been using
>
> ls | egrep -q "OmniFocus.*\.omnilicense"
>
> but it occurs to me that I might be able to use [[ -e ]]
>
> However, I'm not sure what the syntax is. I tried:
>
> if [[ -e "OmniFocus.*.omnilicense" ]]
> then
>
> {take action here}
[...]

matching_files=(OmniFocus.<->.omnilicense(N))
if (($#matching_files)); then...

-- 
Stephane



Messages sorted by: Reverse Date, Date, Thread, Author