Can I filter by file type?

Yes, you can filter by file type using the ls command in combination with wildcard characters. Here are some examples:

To list only directories:

ls -d */

To list only files with a specific extension (e.g., .txt):

ls *.txt

To list only executable files:

ls -l | grep '^-' | grep 'x'

Explanation:

  • -d */: Lists only directories.
  • *.txt: Lists files that end with .txt.
  • grep '^-': Filters the output to show only files (not directories).
  • grep 'x': Filters to show only executable files.

Let me know if you need further assistance!

0 Comments

no data
Be the first to share your comment!