try this
ls -l | awk '{print $8}' | grep -e 's/\....$//'
I presume the awk does what it is supposed to
grep -e still needs the s/from/to/
\. should match the . literally. (You might have to do a "\\." - not
sure without trying. If you use bash, insert a set -x before the line
to see what the shell does with the escaping)
the $ will match the end of the string, so if you have a file that is
all.tar.bz2, it would leave the all.tar and get rid of the .bz2
Walter
Nathan wrote:
On Wednesday 02 April 2008 09:32:11 Kevin Faulkner wrote:
First off, I've been trying to do this for a little while, but keep on
getting dragged off to other things. My goal is to get sed to pull off the
.xxx of the file. So lets say you have documentation.odt timesheet.ods
archive.zip and readme.txt I would like sed to pull off these: ods zip odt
txt. I figured I would do it like this
ls -l |awk '{print $8}'|sed -e '/$\.+++/p
ls -l |awk '{print $8}'|sed -e '/^\.+++/p
(I also used ? in place of the +)
I have also tried this.
ls -l |awk '{print $8}'|grep -e "*\.[a-z]
I'm not sure if I just don't understand sed, or if its a problem with
regular expressions, but either way, I can't get it work. Even * should
work as it is any character. A little guidance would be nice. Thanks folks.
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
how about
ls -l | rev | cut -b5- | rev
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss