Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-08-2005, 11:08 AM   #1
Registered: Mar 2005
Posts: 61

Rep: Reputation: 15
Getting file names in a directory using C on linux.

Hi All,

I need a small program using C to get all file names in a specified directory in linux by giving file type as input (like *.c or *.so).

Thanks in advance,
Suresh B
Old 06-08-2005, 11:26 AM   #2
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38
Why are you trying to reinvent find or ls?
Old 06-08-2005, 11:27 AM   #3
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 124Reputation: 124
rajsun: Use the opendir() function to read the files in a directory.
Old 06-09-2005, 05:03 PM   #4
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36

.. see dirent.h
Old 06-10-2005, 12:47 AM   #5
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
You can also look here:

It's another thread in the same forum, but related to processes...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
awk: fatal:cannot open file for reading (no such file or Directory) in Linux sangati vishwanath Linux - Software 4 07-06-2005 12:59 AM
SSL Install not going well. Linux server, Apache directions? File names not matching. maineweb Linux - Newbie 1 11-18-2004 09:18 AM
monitoring directory to get the modified file names appas Programming 1 09-06-2004 04:56 AM
view long file names from windows in linux wildcat22 Linux - General 4 09-03-2004 04:14 PM
Windows file names in Linux console mbegovic Linux - General 4 04-30-2004 01:09 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:57 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration