sed help

Kevin Faulkner kondor6c at cox.net
Wed Apr 2 13:51:36 MST 2008


On Wed, Apr 02, 2008 at 11:08:46AM -0700, Walter J. Mack wrote:
> Hope this works better...
> 
> 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/
I didn't know that grep could switch text, I thought for sure that was sed that
switches text. Even then I'm not trying to switch text instead I am trying to
get it to print, which is why I'm using /p in sed. 

> \. 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
ls -l|awk '{print $8}'|grep -e "\....$" will print all files that have an
extension.


More information about the PLUG-discuss mailing list