Skip to main content

All Questions

4 votes
2 answers
653 views

How to print a double quote in POSIX scripting?

So far, I've been using "\"" to print a double quote: $ x="abc def" $ echo "x=\"$x\"" x="abc def" However, it seems like that behavior is ...
finefoot's user avatar
  • 3,142
3 votes
1 answer
3k views

Shell command executed differently in a terminal and script

The following sequence of commands ch=`echo "b_d" | sed 's/_/\\\\\\\\_/'` echo $ch when executed in a terminal or via source give an output b\\_d When ran as a scipt sh script.sh where the ...
Viesturs's user avatar
  • 943
0 votes
2 answers
168 views

trying to escape quotes

I have tried numerous ways to print this line in a script: alias myname='export PATH="/path/to/bin:$PATH"' All of them have different problems. The last I tried (and remember!) is: printf '%s' '%s\...
George's user avatar
  • 545
5 votes
4 answers
3k views

Echoing something with multiple quotes and key characters (&, $, !, etc.)

Let's say you have to echo this into a file: RZW"a4k6[)b!^"%*X6Evf How do you do it? My actual "line" to echo is a 2048 characters line.
Issam2204's user avatar
  • 105
4 votes
1 answer
2k views

Printing colored text using script

When I type below command in the shell I get the OUTPUT in green color. Command echo "\033[32mCONNECTING TO abpwrk\033[m"; Output(in green color) CONNECTING TO abpwrk But if I use the same ...
g4ur4v's user avatar
  • 1,774