On Sun, 17 Aug 2008, Brian K. White wrote:- <snip>
A=${1//\"/} # strip quotes A=${A//_/ } # _ to " " A=`echo ${A##*/}` # strip leading path and all extra whitespace A=${A// /_} # " " to _ A=${A//_-_/-} # _-_ to - A=${A%.JPG} # strip trailing .JPG
no sed, no basename, only one spawned shell line 3 the ${A##*/} syntax strips the leading path then the echo command, or rather the shell command line parser, strips the leading and trailing whitespace and collapses all embedded whitespace.
That doesn't work here: davjam@viper-mk2:~> i=" /test/test/tst " davjam@viper-mk2:~> echo "'${i##*/}'" 'tst ' davjam@viper-mk2:~> j=$(echo "${i##*/}") ; echo "'${j}'" 'tst ' This strips off the extra white spaces, but uses two shells: davjam@viper-mk2:~> j=$(echo "${i##*/}"|sed -r -e 's#^ +##' -e 's# +$##' ) ; echo "'${j}'" 'tst' Regards, David Bolt -- Team Acorn: http://www.distributed.net/ OGR-P2 @ ~100Mnodes RC5-72 @ ~15Mkeys SUSE 10.1 32 | | openSUSE 10.3 32b | openSUSE 11.0 32b | openSUSE 10.2 64b | openSUSE 10.3 64b | openSUSE 11.0 64b RISC OS 3.6 | TOS 4.02 | openSUSE 10.3 PPC | RISC OS 3.11 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org