[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to create bash-pattern to exclude a matching param in param expa
From: |
Greg Wooledge |
Subject: |
Re: How to create bash-pattern to exclude a matching param in param expansion&matching? |
Date: |
Wed, 30 Oct 2013 08:06:43 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Wed, Oct 30, 2013 at 12:58:54PM +0100, Andreas Schwab wrote:
> Greg Wooledge <wooledg@eeg.ccf.org> writes:
>
> > On Wed, Oct 30, 2013 at 08:01:02AM +0000, Peggy Russell wrote:
> >> A variation:
> >>
> >> shopt -s nullglob
> >> for f in ${1:-.}/*; do
> >> if [[ "${f}" != *-IGN-* ]];
> >> then printf -- '%s\n' "${f}"
> >> fi
> >> done
> >
> > You missed one set of quotes:
> >
> > for f in "${1:-.}"/*; do
>
> That still won't handle whitespace in file names. Probably better to
> use find instead.
Yes it will. The glob is completely reliable.
imadev:/tmp/greg$ set -- 'dir with spaces'
imadev:/tmp/greg$ for f in "${1:-.}"/*; do printf '%s\n' "$f"; done
dir with spaces/1
dir with spaces/2
dir with spaces/file 3 spaces
- Re: How to create bash-pattern to exclude a matching param in param expansion&matching?, (continued)