Why does echo -e "\\\\ " print only one \
Why does echo -e "\\\\ " print only one \?
echo -e "\\\\\ " prints two. |
From 'man bash'
Quote:
As the -e option actually interprets backslash escapes, the output from the first command is a single backslash. The second command reads the first and second backslashes and outputs a single blackslash, then reads the second and third backslashes and outputs the second blackslash. |
Quote:
So you say that: echo -e "\\\\ " --bash--> echo -e "\\ " --echo -e--> "\ " echo -e "\\\\\ " --bash--> echo -e "\\\ " --echo -e--> "\\ " echo -e "\\\\\\ " --bash--> echo -e "\\\ " --echo -e--> "\\ " In the second line, why would bash preserve the "hanging" last \? In the second and third lines, why would echo -e print the third "hanging" \? They do, as you say, but where is this written in manuals? "" are not really there after bash. |
Please use [code][/code] tags around your code, to preserve formatting and to improve readability. It would help to see what's going on here.
According to the bash man page: Code:
QUOTING Code:
echo [-neE] [arg ...] In all of your lines above, the last character on the line is a space, so what you're really seeing is a literal "\ " combination. Try replacing the space with some other character, and/or bracket the results, to see it more clearly. Also, use the plain echo command to see what the shell is really executing before the -e interpretation further reduces it. Code:
$ echo "[\\\\S]" |
Thank you a lot!!
Quote:
Then, echo -e does the same thing again and this generated those strange results. I take your advices. Thanks again. |
All times are GMT -5. The time now is 05:55 PM. |