On 04/11/2013 03:31 PM, Eric Blake wrote: > But for a full list of all subdirectory names excluding '.' and '..', > you need three globs; and either a shell option that suppresses a glob > that has no match, or ignoring the errors when ls tries to warn you when > a glob doesn't match: > > Portable (but risks hiding errors): > $ ls -d */ .[!.]/ .??*/ 2>/dev/null
Be aware that this also runs the risk of generating too long of a command line if the globs expand to a lot of names; while find specifically avoids exceeding command line length limits. On the other hand, while ls defaults to sorting its output, find does not; so if you need sorted output, you have to start considering the use of non-POSIX extensions such as GNU find's -print0 and sort's -z to generate and sort the list with unambiguous terminators, if you are worried that any of the names found might contain a newline in the name. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature