[Cialug] List file types in a directory

Tim Wilson tim_linux at wilson-home.com
Thu Mar 8 16:20:11 CST 2007


ls -1 | awk -F'.' '{print $NF}' | sort | uniq
or sort -u instead of sort | uniq

I use awk because you could have foo.bar.jpg.  Using NF in awk will
guarantee you'll get jpg.

On 3/8/07, Chris Freeman <cwfreeman at gmail.com> wrote:
> Assuming only one '.' per filename:
>
> ls -1 | cut -f2 -d. | sort -u
>
> Chris
>
>
> On 3/8/07, Daniel Juliano < dan at danandlaurajuliano.com> wrote:
> > So, how would I get a list of file types for all files in a directory?
> > Let's say I've got the following:
> > test1.txt
> > test2.txt
> > test3.jpg
> >
> > I'd like something similar to:
> > .txt
> > .jpg
> >
> > Any ideas?
> >
> >
> > _______________________________________________
> > Cialug mailing list
> > Cialug at cialug.org
> > http://cialug.org/mailman/listinfo/cialug
> >
>
>
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>
>


-- 
Tim


More information about the Cialug mailing list