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

Re: recurse does not work?



On Wed, Nov 20, 2019 at 02:06:07PM +0000, Bonno Bloksma wrote:
> So now  want only the *.sh (shell script)  files 
> 
> beheerdertio@einpingme:~$ ls -R ping/*.sh
> ping/getloss-all.sh  ping/getloss.sh  ping/showloss-today.sh  ping/showtime-today.sh

> But neither recurses into the directories.
> Maybe because none of the directories has a *.sh name, how illogical that sounds, that would make the -R option pretty useless I think.
> But if that is the case then how do I change all the *.sh files in those directories to an executable, other than doing it one by one.

There are a couple ways.

The first one would be to turn on the "globstar" option in bash, and
then use a recursive glob.

shopt -s globstar
chmod whatever ping/**/*.sh

The second way, which is the traditional way, would be to use find(1) to
perform the recursive search, and act on the files that it finds.

find ping -type f -name '*.sh' -exec chmod whatever {} +


Reply to: