How can I make echo or printf in shell ignore a double backslash (\\) and print it as I see it

TheRedPill

I'm trying to enter some ascii word art into my shell script and I'm using two backslashes (\\) together I want echo or printf to print both these backslashes together. Is there something I can put after echo or printf to make them literally print every character within the double quotes (")?

for example I want:

echo -something "
     __      __  __      __
      \\    //    \\    //
       \\  //      \\  //
        \\//        \\//
"

to print

     __      __  __      __
      \\    //    \\    //
       \\  //      \\  //
        \\//        \\//

Exactly how it is.

Jonathan Leffler

Single quotes are your friend; backslash is just an ordinary character inside a single-quoted string. So is every other character except single-quote itself.

echo '
     __      __  __      __
      \\    //    \\    //
       \\  //      \\  //
        \\//        \\//
'

If you needed single quotes in the single-quoted output, you have to write the sequence '\'' to get the single quote:

echo '"single quotes" ('\'') are harder than "backslashes" (\)'

where I included double quotes and backslashes to make it harder to use double quotes around the string. However, you could also write:

echo "\"single quotes\" (') are harder than \"backslashes\" (\\)"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I overwrite multiple lines with echo or printf in shell?

From Dev

How do I print backslash followed by newline with printf?

From Dev

How do I print backslash followed by newline with printf?

From Dev

How can I print "-n" with `echo`?

From Dev

How can I type a backslash with no backslash key?

From Dev

How can I make IBus not ignore ~/.XCompose?

From Dev

How can I make IBus not ignore ~/.XCompose?

From Dev

How can I make MATLAB to ignore a function?

From Dev

How can I make a echo in echo in laravel with curly braces?

From Dev

How can I print multiple character with one printf?

From Dev

How can I check if my function print/echo's something?

From Dev

how i can print some array in echo string

From Dev

How can I colour the output of printf %s in shell?

From Dev

how can i ignore " (double quotes) while loading file in PIG?

From Dev

How can I see print() statements in behave (BDD)

From Dev

How can I see Debug.Print() statements?

From Dev

How can I print these values (see description) in a table?

From Dev

How can I easily see the man page for builtin shell commands?

From Dev

How can I see the verbatim contents of a shell variable?

From Dev

Can I print an object of the class using printf()?

From Dev

How can I make a button print in the display I created? (Tkinter)

From Dev

How can I swap my backspace and backslash?

From Dev

How can I make a website “see me” as a totally new connection?

From Dev

How can I make ssh ignore .ssh/config?

From Dev

How Can I Make Git Ignore Rails Assets?

From Dev

How can I make gitweb ignore whitespace changes?

From Dev

How can I make PHPUnit ignore a file pattern?

From Dev

How can I make ssh ignore .ssh/config?

From Dev

How can I make NetworkManager ignore my wireless card?

Related Related

  1. 1

    How can I overwrite multiple lines with echo or printf in shell?

  2. 2

    How do I print backslash followed by newline with printf?

  3. 3

    How do I print backslash followed by newline with printf?

  4. 4

    How can I print "-n" with `echo`?

  5. 5

    How can I type a backslash with no backslash key?

  6. 6

    How can I make IBus not ignore ~/.XCompose?

  7. 7

    How can I make IBus not ignore ~/.XCompose?

  8. 8

    How can I make MATLAB to ignore a function?

  9. 9

    How can I make a echo in echo in laravel with curly braces?

  10. 10

    How can I print multiple character with one printf?

  11. 11

    How can I check if my function print/echo's something?

  12. 12

    how i can print some array in echo string

  13. 13

    How can I colour the output of printf %s in shell?

  14. 14

    how can i ignore " (double quotes) while loading file in PIG?

  15. 15

    How can I see print() statements in behave (BDD)

  16. 16

    How can I see Debug.Print() statements?

  17. 17

    How can I print these values (see description) in a table?

  18. 18

    How can I easily see the man page for builtin shell commands?

  19. 19

    How can I see the verbatim contents of a shell variable?

  20. 20

    Can I print an object of the class using printf()?

  21. 21

    How can I make a button print in the display I created? (Tkinter)

  22. 22

    How can I swap my backspace and backslash?

  23. 23

    How can I make a website “see me” as a totally new connection?

  24. 24

    How can I make ssh ignore .ssh/config?

  25. 25

    How Can I Make Git Ignore Rails Assets?

  26. 26

    How can I make gitweb ignore whitespace changes?

  27. 27

    How can I make PHPUnit ignore a file pattern?

  28. 28

    How can I make ssh ignore .ssh/config?

  29. 29

    How can I make NetworkManager ignore my wireless card?

HotTag

Archive