You can use printf command with backslash (\) to escape special characters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
printf "\\%s\\%s" "home" "user" ## returns \home\user printf "\a%s" "warning" ## returns warning with bell sound printf "%s\b%s" "hello" "world" ## returns hellworld printf "\f%s\n" "hello world" ## returns hello world clearing the screen printf "%s\n" "hello world" ## prints a new line after hello world printf "%s\r%s" "hello" "world" ## returns world printf "%s\t%s" "hello" "world" ## returns hello world printf "\v%s\n" "hello" ## returns vertical tab and then hello printf "%s\'s" "debjeet" ## returns debjeet's printf "'%s'" "debjeet" ## returns 'debjeet' printf "%s\"s" "debjeet" ## returns debjeet"s printf "\"%s\"" "debjeet" ## returns "debjeet" printf "%s\?" "how are you" ## returns how are you? printf "%s%%" "10" ## returns 10% printf "\e[32m%s" "hello" ## returns hello in green color printf "\004" ## returns ╝ printf "\x5E" ## returns ^ printf "%s" "A\t" "B\t" "C\t" ## returns A\tB\tC\t printf "%b" "A\t" "B\t" "C\t" ## returns A B C printf "%q" "a$ b*c#d'%" ## returns a\$\ b\*c#d\'% |