sed help
der.hans
PLUGd at LuftHans.com
Wed Apr 2 15:39:08 MST 2008
Am 02. Apr, 2008 schwätzte Kevin Faulkner so:
> 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]
ls -ld *.??? | awk '{print $8 }' | sed -re 's/\..{3}$//'
Use -r to turn on extended regex, then {3} to say 3 anythings.
Do you need to care about jpg and jpeg?
If you use the p command, you'll get double the output as sed is already
passing through the changed value.
> 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.
* is any character in globbing, but not in regex. . is any character in
regex. * is 0 or more of whatever in regex. + is one or more of whatever
in regex. ? is 0 or 1 of whatever in regex.
? is one of whatever in globbing. * is 0 or more any combo in globbing.
ciao,
der.hans
--
# https://www.LuftHans.com/ https://LOPSA.org/
# "Communications without intelligence is noise;
# Intelligence without communications is irrelevant."
# Gen. Alfred. M. Gray, USMC
More information about the PLUG-discuss
mailing list