The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-16-2008
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
ls -ltr help

i have to list some file with certain exemption

suppose for example i have two files

file1.log.1

file1.log.1.123

i want ls -ltr command to list only 1st type of files

so i want like this

ls -ltr *.log.*---------it should grep 1st kind of files but this command greps all the files both of type 1 and 2.

plz help me to list only those file of 1st kind
  #2 (permalink)  
Old 01-16-2008
emery emery is offline
Registered User
  
 

Join Date: Oct 2007
Location: Buenos Aires, Argentina
Posts: 1
try ls -ltr | grep ".log.[0-9]$"
  #3 (permalink)  
Old 01-16-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557
Quote:
Originally Posted by ali560045 View Post
i have to list some file with certain exemption

suppose for example i have two files

file1.log.1

file1.log.1.123

i want ls -ltr command to list only 1st type of files

so i want like this

ls -ltr *.log.*---------it should grep 1st kind of files but this command greps all the files both of type 1 and 2.

plz help me to list only those file of 1st kind
how many kinds of type 1 files do you have. For only those 2 types tested

Code:
# ls -ltr *.log.[1-9]

  #4 (permalink)  
Old 01-17-2008
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
thanks now i m able to get 1st kinf of files.........

but 1st kind of files are also like this

file1.log.123

file1.log.12


file1.log.10

ls -ltr *.log.[1-9]--------its grepping those file which have till 9,even i wnt to grep all the numbers like for example file1.log.12.
  #5 (permalink)  
Old 01-17-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557
Quote:
Originally Posted by ali560045 View Post
thanks now i m able to get 1st kinf of files.........

but 1st kind of files are also like this

file1.log.123

file1.log.12


file1.log.10

ls -ltr *.log.[1-9]--------its grepping those file which have till 9,even i wnt to grep all the numbers like for example file1.log.12.
if you are sure you do not have any other characters beside numbers

Code:
ls -ltr *.log.? *.log.?? *.log.???

or

Code:
ls -ltr *.log.[0-9]*

or just

Code:
ls -ltr *.log.[0-9]  *.log.[0-9] [0-9] *.log.[0-9] [0-9][0-9]

If you have other more advanced criteria, then the above doesn't really suit your needs....
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0