help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Transform strings with special characters so that the st


From: Eduardo A . Bustamante López
Subject: Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?
Date: Tue, 24 Mar 2015 18:20:29 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

You have two options:

printf -v escaped_var %q "$var"

or

shquote() {
  local q=\'
  printf "'%s'" "${1//"$q"/$q\\$q$q}"
}
escaped_var=$(shquote "$var")

-- 
Eduardo Bustamante | https://dualbus.me/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]