Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

List only files based on a pattern

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-09-2012
shash shash is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 7 June 2016, 8:43 AM EDT
Posts: 63
Thanks: 11
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 Unix and Linux 10-09-2012
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 1 December 2016, 5:25 AM EST
Location: In the leftmost byte of /dev/kmem
Posts: 5,225
Thanks: 90
Thanked 1,371 Times in 1,027 Posts
Use the "find" command.

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

I hope this helps.

bakunin
Sponsored Links
    #3  
Old Unix and Linux 10-09-2012
shash shash is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 7 June 2016, 8:43 AM EDT
Posts: 63
Thanks: 11
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 Unix and Linux 10-09-2012
bmk bmk is offline
Registered User
 
Join Date: Dec 2011
Last Activity: 15 November 2016, 10:59 PM EST
Posts: 269
Thanks: 2
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 Unix and Linux 10-09-2012
itkamaraj's Unix or Linux Image
itkamaraj itkamaraj is offline Forum Advisor  
Registered User
 
Join Date: Apr 2010
Last Activity: 2 December 2016, 3:48 AM EST
Posts: 3,126
Thanks: 43
Thanked 684 Times in 660 Posts

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

Sponsored Links
    #6  
Old Unix and Linux 10-09-2012
elixir_sinari's Unix or Linux Image
elixir_sinari elixir_sinari is offline Forum Advisor  
Registered User
 
Join Date: Mar 2012
Last Activity: 29 November 2016, 6:07 AM EST
Location: India
Posts: 1,413
Thanks: 101
Thanked 497 Times in 474 Posts
If you can use ls, try:

Code:
ls !(*.*)

Note: Turn on extglob in bash (shopt -s extglob).
Sponsored Links
    #7  
Old Unix and Linux 10-09-2012
shash shash is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 7 June 2016, 8:43 AM EDT
Posts: 63
Thanks: 11
Thanked 0 Times in 0 Posts
Thanks all it worked Linux
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 01:11 PM
Moving multiple files based on the pattern rudoraj UNIX for Advanced & Expert Users 1 05-16-2012 06:50 PM
print multiple lines from text file based on pattern list Oyster UNIX for Dummies Questions & Answers 1 09-14-2011 05:43 PM
how to list files with certain pattern aoussenko Shell Programming and Scripting 2 02-19-2009 01:47 PM
using sed to replace a pattern in list of files a1_win Shell Programming and Scripting 4 08-07-2008 08:18 AM



All times are GMT -4. The time now is 02:00 AM.