List only files based on a pattern | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

List only files based on a pattern

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-09-2012
shash shash is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 24 September 2014, 5:11 AM EDT
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
List only files based on a pattern

Hi Gurus,

I need to list only the files with out certain extension.

For eg from the following list of files:

Quote:
file1
file1.20120130
file1.20120225
file2
file2.20120115
file2.20120320
I need to only list:

Quote:
file1
file2
Thanks
Shash
Sponsored Links
    #2  
Old 10-09-2012
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 21 October 2014, 4:27 AM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 4,282
Thanks: 45
Thanked 824 Times in 651 Posts
Use the "find" command.

You can find a short introduction to "find" here.

I hope this helps.

bakunin
Sponsored Links
    #3  
Old 10-09-2012
shash shash is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 24 September 2014, 5:11 AM EDT
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Apologies, if I 'm not clear enough. I have thousands of file with different names. I need to find the files with out a decimal place followed by a date in the file name which has been showed in the example.
    #4  
Old 10-09-2012
bmk bmk is offline
Registered User
 
Join Date: Dec 2011
Last Activity: 31 October 2013, 9:16 AM EDT
Posts: 262
Thanks: 1
Thanked 22 Times in 22 Posts
if the extension of the .txt file...
try like...

Code:
 ls test?.???

---------- Post updated at 07:40 AM ---------- Previous update was at 07:36 AM ----------

if is numbers only try like..


Code:
ls test[1-9].???

Sponsored Links
    #5  
Old 10-09-2012
itkamaraj's Avatar
itkamaraj itkamaraj is offline Forum Advisor  
^Kamaraj^
 
Join Date: Apr 2010
Last Activity: 3 October 2014, 8:50 AM EDT
Posts: 3,059
Thanks: 33
Thanked 659 Times in 638 Posts

Code:
ls | awk -F. 'NF==1'

Sponsored Links
    #6  
Old 10-09-2012
elixir_sinari's Avatar
elixir_sinari elixir_sinari is offline Forum Advisor  
Registered User
 
Join Date: Mar 2012
Last Activity: 9 October 2014, 4:50 PM EDT
Location: India
Posts: 1,412
Thanks: 101
Thanked 496 Times in 473 Posts
If you can use ls , try:

Code:
ls !(*.*)

Note: Turn on extglob in bash ( shopt -s extglob ).
Sponsored Links
    #7  
Old 10-09-2012
shash shash is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 24 September 2014, 5:11 AM EDT
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks all it worked
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Copying files based on a pattern 969murali@gmail Shell Programming and Scripting 7 06-26-2012 12:11 PM
Moving multiple files based on the pattern rudoraj UNIX for Advanced & Expert Users 1 05-16-2012 05:50 PM
print multiple lines from text file based on pattern list Oyster UNIX for Dummies Questions & Answers 1 09-14-2011 04:43 PM
how to list files with certain pattern aoussenko Shell Programming and Scripting 2 02-19-2009 12:47 PM
using sed to replace a pattern in list of files a1_win Shell Programming and Scripting 4 08-07-2008 07:18 AM



All times are GMT -4. The time now is 09:31 AM.