LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-14-2008, 11:08 AM   #1
jianelisj
LQ Newbie
 
Registered: Mar 2008
Posts: 18

Rep: Reputation: 0
Select the files of a directory that match a specific pattern


How can i select the files of a directory that match a specific pattern
eg *.h

My idea is: if [$filename == $pattern]
......

is this correct or not? Please any help
 
Old 03-14-2008, 11:15 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,770

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
find /<directory name> -type f | grep .h , where <directory name> is the path and directory to search.

To use that information in a loop, such as a for-next loop:
for i in $(find /<directory name> -type f | grep .h); do something; done

Last edited by bigrigdriver; 03-14-2008 at 11:17 AM.
 
Old 03-17-2008, 12:25 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Quote:
Originally Posted by jianelisj View Post
How can i select the files of a directory that match a specific pattern
eg *.h

My idea is: if [$filename == $pattern]
......

is this correct or not? Please any help

What do you mean by select, what does your training material
suggest you might be wanting to use?

Do your own homework.
 
  


Reply


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
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 06:17 AM
perl pattern match question lluciano Programming 4 02-28-2006 05:59 AM
No longer able to select files from my user home directory oily_rags Suse/Novell 4 11-06-2005 01:39 PM
How to recursively rename files using their directory name pattern ceg4048 Linux - General 2 09-28-2005 01:16 PM
Find string pattern in directory of text files magnum818 Linux - Newbie 2 10-15-2003 08:19 PM


All times are GMT -5. The time now is 01:33 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration