wildcard help

Can someone please explain the wildcards in this. How is this recursive? When I put this in my terminal it recursively displayed everything.

ls .[!.]* *

The above command is not recursive, it's just displays the content of the directories
in the current directory (I mean, it's just like ls <directory_name> ).

The pattern .[!.]* matches filenames the begin with a literal dot (.), followed by a character different from a dot,
followed by 0 or more characters of any type. The following * matches any number of non-dot characters characters.

I think it's the same as:

ls .??* * 2>/dev/null

i.e. List the directory without the "." and ".." files which you would get from "ls -a".

If you are not interested in the contents of subdirectories (which is maybe why you mention "recursive"?).

ls -d .??* * 2>/dev/null

Why not just use

ls -a

Because that includes "." and ".." . The idea of the script in post #1 is to show the hidden files (like ".profile") but not the "." and ".." files.

use the uppercase then (if this option is available on your OS) :

ls -A
1 Like

I am trying to understand someones shellscript.

Thank you for explaining :).