LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 10-01-2007, 06:25 AM   #1
basak
Member
 
Registered: Jul 2006
Posts: 41

Rep: Reputation: 15
wildcard characters for ls


Hi!

I am trying to implement linux "ls" command just with system calls and until now I have succeded in listing a directory (with a given full path )and taking information about the files in there by opendir,readdir,stat system calls.But I also want to handle the wildcard characters '*' and '?' in the search pattern.Namely select only files which match the pattern containing these wildcards.Is there an easy way in handling that?Thank you
 
Old 10-01-2007, 06:37 AM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
I think you're going to have to tell us what language you are programming in. A little more detail is always useful in getting an answer.
 
Old 10-01-2007, 06:43 AM   #3
basak
Member
 
Registered: Jul 2006
Posts: 41

Original Poster
Rep: Reputation: 15
I am programming in c++.Thanks again.
 
Old 10-01-2007, 03:52 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by basak View Post
But I also want to handle the wildcard characters '*' and '?' in the search pattern.Namely select only files which match the pattern containing these wildcards.
IIRC, most wildcard/globbing happens in the shell prior to executing ls (or any executable for that matter). For this, the shell uses the POSIX-specified glob() and wordexp().

Utilities like ls, however, may need to implement filename matching for correct unix-path expansion. In this case, one might use the POSIX-specified fnmatch().
 
  


Reply



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
Sudo Wildcard Cottsay Linux - Software 2 06-11-2007 07:11 PM
wildcard emails using postfix rezaan.marlie Linux - Newbie 3 05-17-2007 08:37 AM
Using wildcard characters mlink4 Red Hat 1 01-26-2007 05:06 AM
How to modify the names of files and replace characters with other characters or symb peter88 Linux - General 2 12-10-2006 03:05 AM
I choose you wildcard! tearinox Linux - Newbie 2 01-23-2004 08:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:36 AM.

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