<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks all who replied, awesome answers! If I had to rate a winner, I
give it to Tim, as my usage looks like:<br>
<pre wrap="">ls -1 -R /home/djuliano | awk -F'.' '{print $NF}' | sort | uniq</pre>
And his output is perfect for what I want. The next question would be
how to get counts by file type.<br>
<br>
I'm going to read up on awk, as I've always read it's a language unto
itself. Something about sed being part of the mix usually, dunno how
the two interact.<br>
<br>
Dan<br>
<br>
<br>
Daniel A. Ramaley wrote:
<blockquote cite="mid200703081643.24447.daniel.ramaley@drake.edu"
type="cite">
<pre wrap="">Like this?
$ ls | perl -ne 'print "$1\n" if /\.([^.]*?)$/;'
That prints the file extension for files that have one. For files that
don't have an extension, nothing is printed.
On Thursday 08 March 2007 16:39, Kendall Bailey wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Not simple enough for a single command line, but here's a python
script which will play the role of awk in the pipeline shown
import sys,re
for i in sys.stdin :
if re.match(".*\.([^.])+",i.strip()) : print
i.strip().split(".")[-1]
I'm sure it would be a one liner in perl...
On 3/8/07, David Champion <a class="moz-txt-link-rfc2396E" href="mailto:dchampion@visionary.com"><dchampion@visionary.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Both of those methods will display files with no periods, i.e. put a
file in there called "test" and it will echo out "test".
-dc
Tim Wilson wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:cwfreeman@gmail.com"><cwfreeman@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Assuming only one '.' per filename:
ls -1 | cut -f2 -d. | sort -u
Chris
On 3/8/07, Daniel Juliano < <a class="moz-txt-link-abbreviated" href="mailto:dan@danandlaurajuliano.com">dan@danandlaurajuliano.com</a>> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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
<a class="moz-txt-link-abbreviated" href="mailto:Cialug@cialug.org">Cialug@cialug.org</a>
<a class="moz-txt-link-freetext" href="http://cialug.org/mailman/listinfo/cialug">http://cialug.org/mailman/listinfo/cialug</a>
</pre>
</blockquote>
<pre wrap="">_______________________________________________
Cialug mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Cialug@cialug.org">Cialug@cialug.org</a>
<a class="moz-txt-link-freetext" href="http://cialug.org/mailman/listinfo/cialug">http://cialug.org/mailman/listinfo/cialug</a>
</pre>
</blockquote>
</blockquote>
<pre wrap="">_______________________________________________
Cialug mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Cialug@cialug.org">Cialug@cialug.org</a>
<a class="moz-txt-link-freetext" href="http://cialug.org/mailman/listinfo/cialug">http://cialug.org/mailman/listinfo/cialug</a>
</pre>
</blockquote>
<pre wrap="">_______________________________________________
Cialug mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Cialug@cialug.org">Cialug@cialug.org</a>
<a class="moz-txt-link-freetext" href="http://cialug.org/mailman/listinfo/cialug">http://cialug.org/mailman/listinfo/cialug</a>
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>