Skip to main content

To list only hidden files:

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

Note that files here is everything that is not a directory. It's not file in "everything in Linux is a file" ;)

To list only hidden directories:

ls -ap | egrepgrep "^\..*/$" 

Comments:

  • 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 /.
  • If you want to exclude . and .. directories from results of the second part, you can use -A option instead of -a for ls, or if you like to work with regex, you can use "^\.[^.]+/$" instead of "^\..*/$".

Have fun!

To list only hidden files:

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

Note that files here is everything that is not a directory. It's not file in "everything in Linux is a file" ;)

To list only hidden directories:

ls -ap | egrep "^\..*/$" 

Comments:

  • 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 /.
  • If you want to exclude . and .. directories from results of the second part, you can use -A option instead of -a for ls, or if you like to work with regex, you can use "^\.[^.]+/$" instead of "^\..*/$".

Have fun!

To list only hidden files:

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

Note that files here is everything that is not a directory. It's not file in "everything in Linux is a file" ;)

To list only hidden directories:

ls -ap | grep "^\..*/$" 

Comments:

  • 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 /.
  • If you want to exclude . and .. directories from results of the second part, you can use -A option instead of -a for ls, or if you like to work with regex, you can use "^\.[^.]+/$" instead of "^\..*/$".

Have fun!

adding extra info
Source Link
Mohammad
  • 738
  • 5
  • 19

To list only hidden files:

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

Note that files here is everything that is not a directory. It's not file in "everything in Linux is a file" ;)

To list only hidden directories:

ls -ap | egrep "^\..*/$" 

Comments:

  • 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 /.
  • If you want to exclude . and .. directories from results of the second part, you can use -A option instead of -a for ls, or if you like to work with regex, you can use "^\.[^.]+/$" instead of "^\..*/$".

Have fun!

To list only hidden files:

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

Note that files here is everything that is not a directory. It's not file in "everything in Linux is a file" ;)

To list only hidden directories:

ls -ap | egrep "^\..*/$" 

Comments:

  • 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 /.
  • If you want to exclude . and .. directories from results, you can use -A option instead of -a for ls.

To list only hidden files:

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

Note that files here is everything that is not a directory. It's not file in "everything in Linux is a file" ;)

To list only hidden directories:

ls -ap | egrep "^\..*/$" 

Comments:

  • 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 /.
  • If you want to exclude . and .. directories from results of the second part, you can use -A option instead of -a for ls, or if you like to work with regex, you can use "^\.[^.]+/$" instead of "^\..*/$".

Have fun!

adding extra info
Source Link
Mohammad
  • 738
  • 5
  • 19

To list only hidden files:

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

Note that files here is everything that is not a directory. It's not file in "everything in Linux is a file" ;)

To list only hidden directories:

ls -ap | egrep "^\..*/$"  

Comments:

  • 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 /.
  • If you want to exclude . and .. directories from results, you can use -A option instead of -a for ls.

To list only hidden files:

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

To list only hidden directories:

ls -ap | egrep "^\..*/$" 
  • 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 /.

To list only hidden files:

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

Note that files here is everything that is not a directory. It's not file in "everything in Linux is a file" ;)

To list only hidden directories:

ls -ap | egrep "^\..*/$"  

Comments:

  • 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 /.
  • If you want to exclude . and .. directories from results, you can use -A option instead of -a for ls.
an edit
Source Link
Mohammad
  • 738
  • 5
  • 19
Loading
an edit
Source Link
Mohammad
  • 738
  • 5
  • 19
Loading
corrected a little mistake
Source Link
Mohammad
  • 738
  • 5
  • 19
Loading
a correct answer
Source Link
Mohammad
  • 738
  • 5
  • 19
Loading
Source Link
Mohammad
  • 738
  • 5
  • 19
Loading