Operating System - Linux
1827810 Members
1903 Online
109969 Solutions
New Discussion

File listing question (ll, ls.....)

 
SOLVED
Go to solution
Joe Profaizer
Super Advisor

File listing question (ll, ls.....)

I have a need to list all files with an extention (i.e. 8.3 or whatever). How can I list all files under a mountpoint where it lists the extension from the rightmost ".". For example, I would want to list filename extensions, but use the rightmost "." in the filename as my search criteria instead of reading the filename from left to right. I need to read the file from right to left.

Is this possible?
3 REPLIES 3
Vernon Brown_2
Frequent Advisor

Re: File listing question (ll, ls.....)

Why wouldn't just this work?

ls -l *.whatever
Joe Profaizer
Super Advisor

Re: File listing question (ll, ls.....)

Because some filenames have more than one "." in it.

Bill Thorsteinson
Honored Contributor
Solution

Re: File listing question (ll, ls.....)

Try

ls *.txt

This will list all the .txt files.

To get a list of all the files by extention try this shell code.

ext=$(
for file in *.*; do
echo ${file##*.}
done | sort | uniq)

for x in $ext; do
ls *.$x
done