Nerius Landys <[email protected]> wrote:

> Is there a function, or command line utility, to "escape" a string,
> making it suitable to be input on the command line?  For example, this
> "escape" utility would take a input of "te st" and create an output of
> "te\ st".  Other things such as quotes and single quotes would be
> handled as well.

You can use something like this:  sed 's/[^A-Za-z_0-9]/\\&/'

Perl has a quotemeta() function and \Q escape sequence for this
purpose, e.g.:

$ perl -e '$_="te st"; print "\Q$_\E\n"'
te\ st

-- 
Christian "naddy" Weisgerber                          [email protected]

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[email protected]"

Reply via email to