Skip to main content
update for huge trees
Source Link

Yet another way to achieve it is

 print *(/)

or

 echo *(/)

Update1

A bit more correct version (as noted by @Stéphane Chazelas) would be

print -rl -- *(/) 

or

echo -E - *(/)

respectively to take care about spaces (-l), escape sequences (-r/-E) and leading hyphens (--/-) inside filenames.

Update2

Yet even more correct version is print -rN which additionally takes care of linebreaks inside filenames (linux allows them, windows doesn't) by separating the results with nulls, for example:

print -NrN -- **/*(/) |sudo xargs|xargs -0 -n10 chmod g+s

which recursively sets setguid bit - selectively addressing directories, as opposed to chmod -R g+s.

Update3

For huge trees this only processes a part of files (due to the limit on command line length) and silently leave the rest as is. The following commands can handle this situation:

find . -type d -print0 |xargs -0 -n10 chmod g+s

Yet another way to achieve it is

 print *(/)

or

 echo *(/)

Update1

A bit more correct version (as noted by @Stéphane Chazelas) would be

print -rl -- *(/) 

or

echo -E - *(/)

respectively to take care about spaces, escape sequences and leading hyphens inside filenames.

Update2

Yet even more correct version is print -rN which additionally takes care of linebreaks inside filenames (linux allows them, windows doesn't) by separating the results with nulls, for example:

print -N -- **/*(/) |sudo xargs -0 -n10 chmod g+s

which recursively sets setguid bit - selectively addressing directories, as opposed to chmod -R g+s.

Yet another way to achieve it is

 print *(/)

or

 echo *(/)

Update1

A bit more correct version (as noted by @Stéphane Chazelas) would be

print -rl -- *(/) 

or

echo -E - *(/)

to take care about spaces (-l), escape sequences (-r/-E) and leading hyphens (--/-) inside filenames.

Update2

Yet even more correct version is print -rN which additionally takes care of linebreaks inside filenames (linux allows them, windows doesn't) by separating the results with nulls, for example:

print -rN -- **/*(/) |xargs -0 -n10 chmod g+s

which recursively sets setguid bit - selectively addressing directories, as opposed to chmod -R g+s.

Update3

For huge trees this only processes a part of files (due to the limit on command line length) and silently leave the rest as is. The following commands can handle this situation:

find . -type d -print0 |xargs -0 -n10 chmod g+s
minor improvements
Source Link

*   YetYet another way to achieve it is

 print *(/)

or

 echo *(/)

UpdateUpdate1

*  AA bit more correct version (as noted by @Stéphane Chazelas) would be

print -rl -- *(/) 

or

echo -E - *(/)

respectively to take care about spaces and, escape sequences and leading hyphens inside filenames.

*   YetUpdate2

Yet even more correct version is print -rN which additionally takes care of linebreaks inside filenames (linux allows them, windows doesn't) by separating the results with nulls, for example:

print -N -- **/*(/) |xargs|sudo -0xargs -n10 -i echo cpn10 {}chmod {}~g+s

which is a "preview" version of creating a backup of all subdirectories in current dirrecursively sets setguid bit - selectively addressing directories, as opposed to chmod -R g+s.

*   Yet another way to achieve it is

 print *(/)

or

 echo *(/)

Update

*  A bit more correct version (as noted by @Stéphane Chazelas) would be

print -rl -- *(/) 

or

echo -E - *(/)

respectively to take care about spaces and escape sequences inside filenames.

*   Yet even more correct version is print -rN which takes care of linebreaks inside filenames by separating the results with nulls, for example:

print -N -- *(/) |xargs -0 -n1 -i echo cp {} {}~

which is a "preview" version of creating a backup of all subdirectories in current dir.

Yet another way to achieve it is

 print *(/)

or

 echo *(/)

Update1

A bit more correct version (as noted by @Stéphane Chazelas) would be

print -rl -- *(/) 

or

echo -E - *(/)

respectively to take care about spaces, escape sequences and leading hyphens inside filenames.

Update2

Yet even more correct version is print -rN which additionally takes care of linebreaks inside filenames (linux allows them, windows doesn't) by separating the results with nulls, for example:

print -N -- **/*(/) |sudo xargs -0 -n10 chmod g+s

which recursively sets setguid bit - selectively addressing directories, as opposed to chmod -R g+s.

separate args from opts
Source Link

*   Yet another way to achieve it is

 print *(/)

or

 echo *(/)

Update

*  A bit more correct version (as noted by @Stéphane Chazelas) would be

print -rl -- *(/) 

or

echo -E - *(/)

respectively to take care about spaces and escape sequences inside filenames.

*   Yet even more correct version is print -rN which takes care of linebreaks inside filenames by separating the results with nulls, for example:

print -N -- *(/) |xargs -0 -n1 -i echo cp {} {}~

which is a "preview" version of creating a backup of all subdirectories in current dir.

*   Yet another way to achieve it is

 print *(/)

or

 echo *(/)

Update

*  A bit more correct version (as noted by @Stéphane Chazelas) would be

print -rl -- *(/) 

or

echo -E - *(/)

respectively to take care about spaces and escape sequences inside filenames.

*   Yet even more correct version is print -rN which takes care of linebreaks inside filenames by separating the results with nulls, for example:

print -N *(/) |xargs -0 -n1 -i echo cp {} {}~

which is a "preview" version of creating a backup of all subdirectories in current dir.

*   Yet another way to achieve it is

 print *(/)

or

 echo *(/)

Update

*  A bit more correct version (as noted by @Stéphane Chazelas) would be

print -rl -- *(/) 

or

echo -E - *(/)

respectively to take care about spaces and escape sequences inside filenames.

*   Yet even more correct version is print -rN which takes care of linebreaks inside filenames by separating the results with nulls, for example:

print -N -- *(/) |xargs -0 -n1 -i echo cp {} {}~

which is a "preview" version of creating a backup of all subdirectories in current dir.

more correct versions
Source Link
Loading
Source Link
Loading