How to list files only?

To list files only (excluding directories) in a directory using the ls command, you can use the following command:

ls -p | grep -v /

Here's what this command does:

  • ls -p: Lists all files and directories, appending a / to directory names.
  • grep -v /: Filters out any lines that contain a /, effectively showing only files.

This will give you a list of files in the current directory without including any directories.

0 Comments

no data
Be the first to share your comment!