[SWLUG] Find And Replace.

Geraint Edwards gedge-lists-swlug at yadn.org
Thu Jan 7 16:25:26 UTC 2010


Ysgrifennodd David Scourfield <david.scourfield at llynfi.co.uk> said
		(on Thu, Jan 07, 2010 at 03:57:48PM +0000):
> tested this, which works on subdirectory entries too:
>     tgt=$(echo $i | sed -e "s/-/ - /")

No, this will only change one dash, e.g.
	/Music/A-D/foo-bar.mp3
will become
	/Music/A - D/foo-bar.mp3

If, instead, you wanted
	/Music/A - D/foo - bar.mp3
you will need the global flag on sed
	tgt=$(echo $i | sed -e "s/-/ - /g")
but, to save an external sed, I'd use
	tgt=${tgt//-/ - }

-- 
Geraint A. Edwards (aka "Gedge")
gedge at yadn.org



More information about the Swlug mailing list