![](https://seccdn.libravatar.org/avatar/b9171464f4629a0067d23c63bbdeaca4.jpg?s=120&d=mm&r=g)
On Wed, 2003-06-18 at 04:37, Jerry A! wrote:
For sh/ksh88 do the following:
for i in `ls -d *SNG*`; do mv $i `echo $i | sed 's/\.SNG//g' done
While this example might be easy to follow, it on two occasions invoke external binaries, 'ls' and 'sed', which in turn invoke another copy of the shell. It is ineffective. The snippet I suggested last night does not. If you are doing something like this, but for say 100,000 files, you want your script to invoke as little as possible outside itself. The use of %, %%, # and ## can cut down drastically the amount of sed usage and therefor do a significant amount for the speed and resource usage of your script.
: Yeah, ksh can do '%%' like someone else suggested.
ksh93 also supports sed-like substitions.
This was a feature I was unaware of. Now that I know it is there, I'll
be making good use of it. :)
Regards,
--
Anders Karlsson