List only regular file names in a directory

How to List only regular file names in a directory on Linux and Windows

Listing regular files in a directory without including . and .. files.
  • On Linux



    Solution 1:$ ls -p | grep -v /
    Solution 2: $ ls -F | grep -v '[/@=|]'
    Solution 3: $for list in `ls` ; do ls -ld $list | grep -v ^d > /dev/null && echo $list ; done ;
    Solution4:$ for list in `ls` ; do ls -ld $list | grep ^d > /dev/null || echo $list ; done ;
    Solution5 (exclude sym links):$ for list in `ls` ; do ls -ld $list | grep -v ^l > /dev/null && echo $list ; done ;
  • On Windows



    Solution 1: dir /a-d /b >..\File_List.txt

Filed under

Related articles

Level up your Tech Career with DjamgaTech PRO

Download the DjamgaTech PRO App on the Apple App Store to access hundreds of interactive prep questions, flashcards, and quizzes cleanly without ads.

Advertisement
Djamgatech PRO App
Download DjamgaTech PRO on the App Store 🚀

← All articles