Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ls files with numerical extension only 1

Status
Not open for further replies.

new2unix

Programmer
Feb 5, 2001
143
US
Hi,

I tried to ls a directoy with "ls -l *.[0-9]*" in an attemp to list only files having numerical type extension. For example, for the following 2 files:

filename1.12345
filename1.ABCDE
filename1.123A5

I want ls only filename1.12345. The command ls-l *.[0-9]* skipped the filename1.ABCDE but also listed filename1.123A5, which should really be skipped. Can anyone suggested another way to do this?

Thanks

Mike
 
Try: - ls -l *.[0-9]*|grep -v "\..*[A-Z]"

Ged Jones

Top man
 
Hi,

Thanks all who replied. The following seemed to work on my AIX box:

ls -l *.[0-9]* | grep -v "\..*[A-Z]"

It gave me only files with all numeric extension.

I couldn't use the suggestion "ls *.[0-9][0-9][0-9][0-9][0-9]" because the number of digit is not constant. My mistake, should have been a little specific with my question. I also tried "ls -l *.[^A-Za-z]" but, somehow, my AIX didn't filtered out those with extension like ".123A5" or ".1A345". According to my Unix reference, the original "ls -l *.[0-9]*" should have worked.

Also, I am still a little unclear on the grep syntax where the "*" is in front of [A-Z], rather than behind it like [0-9]*, which represent this criteria can repeat many times.

Thanks

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top