Skip to main content
4 of 8
an edit
Mohammad
  • 738
  • 5
  • 19

To list only hidden files:

ls -ap | grep -v / | grep -e "^\." 

To list only hidden directories:

ls -ap | grep -e "^\..*/$" 
  • ls -ap lists everything in the current directory, including hidden ones, and puts a / at the end of directories.
  • grep -v / inverts results of grep /, so that no directory is included.
  • "^\..*/$" matches everything that start with . and end in /.
Mohammad
  • 738
  • 5
  • 19