Show only hidden files (dot files) in ls alias
Have the shell list the dot files, and tell ls
not to see through directories:
ls -d .*
Either make the inner pair of quotes double quotes:
alias hidden='ls -a | grep "^\."'
Or make the outer pair of quotes double quotes:
alias hidden="ls -a | grep '^\.'"
Or make all quotes double quotes and escape the inner pair:
alias hidden="ls -a | grep \"^\.\""
Or make it a function, so you can pass some arguments when calling:
hidden() { ls -a "$@" | grep '^\.'; }
ls -Ad .* #This will list all the hidden files & directories while retaining the color & formatting
OR
To create an alias of the same:
alias lh='ls -Ad .*'
OR
Same thing could be done via grep command and pipe operator; however it would loose the color and formatting:
ls -a|grep "^\."
OR
Via alias:
alias lh='ls -a|grep "^\."'