On Sun, 28 Jun 2015 14:46:01 +0200
Patrice Clement <[email protected]> wrote:
> man 3 glob
> man 3 fnmatch
> man 1 bash -> read the section called "Pattern Matching" under
> "EXPANSION".
>
> in this case, $(ls) would unnecessarily spawn a subshell for listing
> files. You can often get the same result by using wildcard expansion
> (or globbing) like Michal said:
>
> for lang in *; do
> ...
> done
>
> It is often faster.
and it avoids aliases:
/etc $ echo $(ls)
total 1.7M drwxr-xr-x 4 root root 4.0K Aug 29 2014 acpi -rw-r--r-- 1
root root 44 Oct 6 2014 adjtime drwxr-xr-x 2 root root 4.0K Jun 26
19:27 adobe drwxr-xr-x 3 root root 4.0K Mar 22 15:46 ardour3 drwxr-xr-x
3 root root 4.0K May 8 13:14 ardour4 drwxr-xr-x 2 root root 4.0K Jun 15
17:06 at-spi2 drwxr-xr-x 3 root root etc.
I doubt that is what is wanted
However, beware of empty directories:
/tmp/toto $ ls
total 0
/tmp/toto $ for a in *; do echo $a; done
*