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

Re: Filename Expansion



> I am writing a script to search files in a certain pattern
> and manipulate them. Something like:
> 
> 	for i in *.vhd; do
>  		# do some operation on $i here
> 	done
> 	# do other stuff
> 
> 
> This works fine if there is at least one file matches the
> pattern. Otherwise, it exits with an error and 'other stuff'
> never gets done.
> 
> How can I make it so that it will just skip 'for' loop if
> there aren't any files matches the pattern?


for i in *.vhd(N); do
   # do some stuff
done

The (N) says to use the nullglob option for this particular
glob pattern.

Richard Coleman
coleman@xxxxxxxxxxxxxxx



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