help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] if exist


From: Greg Wooledge
Subject: Re: [Help-bash] if exist
Date: Mon, 15 May 2017 08:23:20 -0400
User-agent: Mutt/1.4.2.3i

On Sat, May 13, 2017 at 07:46:08AM -0500, John McKown wrote:
> find "${dat0}" -mindepth 1 -maxdepth 1 -type f -regexptype egrep -regex
> '.*[0-9]$' | xargs -I {} cp -a {} "${dat1}"

Why would you use
-regexptype egrep -regex '.*[0-9]$'

when you could simply (and portably!) use
-name '*[0-9]'

That said, with -mindepth 1 and -maxdepth 1, it looks like you are not
recursing at all.  So you could just use a glob.

cd "$someplace" || exit
for file in *[0-9]; do
  base=${file%[0-9]}
  whatever "$file" "$base"
  ....
done



reply via email to

[Prev in Thread] Current Thread [Next in Thread]