List only regular file names in a directory

You can translate the content of this page by selecting a language in the select box.

AI Unraveled: Demystifying Frequently Asked Questions on Artificial Intelligence

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

    Achieve AWS Solutions Architect Associate Certification with Confidence: Master SAA Exam with the Latest Practice Tests and Quizzes illustrated

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

error: Content is protected !!