help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] if exist


From: John McKown
Subject: Re: [Help-bash] if exist
Date: Mon, 15 May 2017 07:26:07 -0500

On Mon, May 15, 2017 at 7:23 AM, Greg Wooledge <address@hidden> wrote:

> 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]'
>

​I'm insane? [grin]. Or I've been brain damaged by too much PERL?​



>
> 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
>



-- 
Advertising is a valuable economic factor because it is the cheapest way of
selling goods, particularly if the goods are worthless. -- Sinclair Lewis


Maranatha! <><
John McKown


reply via email to

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