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

Etienne Noumen

Sports Lover, Linux guru, Engineer, Entrepreneur & Family Man.

Recent Posts

Tips for Ensuring Success Throughout Your Career

For most people, a satisfactory career is essential for leading a happy life. However, ensuring…

19 hours ago

Different Career Paths in the Pipeline Industry

The pipeline industry is more than pipework and construction, and we explore those details in…

19 hours ago

SQL Interview Questions and Answers

SQL Interview Questions and Answers In the world of data-driven decision-making, SQL (Structured Query Language)…

1 week ago

Things To Consider When Switching Internet Providers

Before you make the decision to switch your home’s interest service provider, take the time…

3 weeks ago

A Daily Chronicle of AI Innovations in April 2024

AI Innovations in April 2024. Welcome to the April 2024 edition of the Daily Chronicle,…

4 weeks ago

Everything To Know About Bioreactors and How They Work

A bioreactor is the silent hero behind the scenes contributing to many of everyday life’s…

4 weeks ago