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 backslash
  • echo '<ca>' — enclose string in single quotes
  • echo "<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

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -