How to echo a new line which has < -
i want echo line has following:
<ca> -----begin certificate----- miidyzccazsgawibagijakrtpjsivek1ma0gcsqgsib3dqebbquamiggmqswcqyd
i tried
echo <^<ca>^>
but didn't work.
you have 3 main options:
echo \<ca\>
— escape special characters backslashecho '<ca>'
— enclose string in single quotesecho "<ca>"
— enclose string in double quotes
if line stored in variable, third way (double quotes) works:
line="<ca>" # written 3 ways echo "$line" # old-fashioned safe way (preserves spacing if there spaces) echo $line # new-fashioned unsafe way, imnsho
the 'new-fashioned' way safe in angle brackets won't interpreted i/o redirections. it's unsafe in loses spacing. recommend using double quotes always; work*.
$ line="< aa bb cc >" $ echo "$line" < aa bb cc > $
* double quotes unnecessary referring contexts [[ ... ]]
conditionals. i'd rather not deal unnecessary special cases; using double quotes works correctly in context too, don't spend time remembering when can safely omit double quotes — double quotes work, use them.
Comments
Post a Comment