Bash: Literal string for special characters in printf

183 views Asked by At

How do you print out the literal string of special character in bash? I always get the expand \t character. For example the code below:

value="0.1"
ln=5
thestring=$(printf $'%si \
    var1=$(dpkg-query -s "$1" |  grep \'Package:\' | sed \'s/^.*: //\') \
    var2=$(grep -m 1 "^$1$(printf \'%s\').*$(printf \'%s\')$value" file.txt) \
' "$ln" "\\t" "\\t")
sed "$thestring" -i somefile.txt

For var2 the \t character is expanded, I expected an output that looks like:

var2=$(grep -m 1 "^$1$(printf '\t').*$(printf '\t')$value" file.txt)

Any idea? Thanks!

0

There are 0 answers