[Gllug] regular expression
Ian Scott
mriscott at yahoo.co.uk
Fri Aug 6 11:06:11 UTC 2004
>
>
> (this i don't get at ALL, could someone please explain me this one)
> sed -e "s/ *//g"
> X.X/XDXiXrXeXcXtXoXrXyXWXiXtXhXSXpXaXcXeXsX/XMXoXrXeXUXrXgXlXyXSXpXaXcXeXsX/XFXiXlXeXNXaXmXeX.XjXaXvXaX
>
>
I'm going to assume here that the line you actually used was
sed -e "s/ */X/g"
- which replaces any number (0 or more) spaces with X
To get what you meant, you'd want:
sed -e "s/ +/X/g"
(replace 1 or more spaces with X)
As others have said, what I think you wanted was:
sed -e "s/ /\\\\ /g"
or
sed -e 's/ /\\ /g'
If you use ", you need to escape the \ twice, once for bash and once for sed.
Ian
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list