List the hidden files in current directory ?

ls -a1 | grep "^\."

2 comments:

Felix Kovacs said...
This comment has been removed by the author.
Felix Kovacs said...

But it also lists . and .. (the current and the parent directory).
If you don't want those two to be listed, use:
ls -a1 |grep "^\.[^.]"
Which says: list every file that begins with a dot and has at least one additional character which is NOT a dot.
So your output will be 2 lines shorter:
$ ls -a1 |grep "^\." |wc -l
16
$ ls -a1 |grep "^\.[^.]" |wc -l
14