{"id":30580,"date":"2018-03-01T20:20:20","date_gmt":"2018-03-01T14:50:20","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=30580"},"modified":"2018-03-01T20:20:20","modified_gmt":"2018-03-01T14:50:20","slug":"using-linux-echo-command-output-text-screen","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/using-linux-echo-command-output-text-screen\/","title":{"rendered":"By Using the Linux Echo Command How to Output Text to the Screen"},"content":{"rendered":"<p>This manual will show you how to output textual content to the terminal window the use of the linux echo command.<\/p>\n<p>Used on its very own in the terminal the echo command isn&#8217;t in particular beneficial but when used as part of the script it may be used to show commands, errors, and notifications.<\/p>\n<h4 id=\"example-uses-of-the-linux-echo-command\"><strong>Example uses of the linux echo command<\/strong><\/h4>\n<p>In its simplest shape the perfect manner to output textual content to the terminal is as follows:<\/p>\n<pre>Echo \"howdy world\"<\/pre>\n<p>The above command outputs the words &#8220;howdy global&#8221; to the screen (minus the citation marks).<\/p>\n<p>By default, the echo announcement outputs a new line character on the give up of the string.<\/p>\n<p>To test this out attempt the subsequent statement in a terminal window:<\/p>\n<pre>Echo \"howdy international\" &amp;&amp; echo \"good-bye world\"<\/pre>\n<p>You may see that the result is as follows:<\/p>\n<pre>Hi there international\r\n\r\nGood-bye international<\/pre>\n<p>You could omit the brand new line man or woman by using adding the minus n switch (-n) as follows:<\/p>\n<pre>Echo -n \"good day international \" &amp;&amp; echo -n \"good-bye world\"<\/pre>\n<p>The result from the above command is as follows:<\/p>\n<pre>Hiya world goodbye international<\/pre>\n<p>Some other issue to consider whilst the use of the echo declaration is the way it handles unique characters.<\/p>\n<p>As an example strive out the following in a terminal window:<\/p>\n<pre>Echo \"howdy worldrngoodbye world\"<\/pre>\n<p>In a perfect global the r and n might act as special characters to add a brand new line however they don&#8217;t. The end result is as follows:<\/p>\n<p>Howdy worldrngoodbye global<\/p>\n<p>You may enable special characters the use of the echo command by using which includes the -e transfer as follows:<\/p>\n<pre>Echo -e \"hiya worldrngoodbye global\"<\/pre>\n<p>This time the end result will be as follows:<\/p>\n<pre>Hi there international\r\n\r\nGoodbye world<\/pre>\n<p>You can of route be in the situation wherein you are attempting to output a string that would be dealt with as a unique individual and you do not want it to. On this situation use a capital e as follows:<\/p>\n<pre>Echo -e \"hi there worldrngoodbye international\"<\/pre>\n<p>Which special characters are handled using the -e transfer?<\/p>\n<ul>\n<li>\\\\ backslash<\/li>\n<li>\\A alert<\/li>\n<li>\\B backspace<\/li>\n<li>\\C produce no in addition output<\/li>\n<li>\\Eescape<\/li>\n<li>\\F shape feed<\/li>\n<li>\\N new line<\/li>\n<li>\\R carriage return<\/li>\n<li>\\T horizontal tab<\/li>\n<li>\\V vertical tab<\/li>\n<li>\\0nnn octal fee with 1 to a few digits<\/li>\n<li>\\xHH byte with hexadecimal value<\/li>\n<\/ul>\n<p>Permit&#8217;s try a couple of these out. Run the subsequent command in a terminal:<\/p>\n<pre>Echo -e \"helblo world\"<\/pre>\n<p>The above command would output the following:<\/p>\n<pre>Hello international<\/pre>\n<p>Obviously now not genuinely what you will want to output to the display screen however you get the factor that backslash b gets rid of the previous letter.<\/p>\n<p>Now strive the following in a terminal window:<\/p>\n<pre>Echo -e \"hello\\c international\"<\/pre>\n<p>This command outputs the whole thing up until the backslash and c. The whole thing else is unnoticed together with the brand new line.<\/p>\n<p>So what is the distinction between a new line person and a carriage return? The brand new line character actions the cursor down to the next line while the carriage return moves the cursor back to the left aspect.<\/p>\n<p>For example input the subsequent into your terminal window:<\/p>\n<pre>Echo -e \"hello\\nworld\"<\/pre>\n<p>The output of the above command places the two phrases on exceptional traces:<\/p>\n<pre>hello\r\n\r\nWorld<\/pre>\n<p>Now strive the subsequent out in a terminal window:<\/p>\n<pre>Echo -e \"hello\\rworld\"<\/pre>\n<p>The distinction among a new line and carriage return turns into very apparent as the subsequent can be displayed as an output:<\/p>\n<pre>World<\/pre>\n<p>The word hello turned into displayed, the carriage go back took the cursor to the start of the line and the phrase global become displayed.<\/p>\n<p>It will become a little more apparent in case you attempt the following:<\/p>\n<pre>Echo -e \"hello\\rhi\"<\/pre>\n<p>The output from the above is as follows:<\/p>\n<pre>Hillo<\/pre>\n<p>In reality the use of many people still use the rn notation whilst outputting to a new line. Pretty often, but, you may break out with just a n.\u200b<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Used on its very own in the terminal the echo command isn&#8217;t in particular beneficial but when used as part of the script it may be used to show commands<\/p>\n","protected":false},"author":2,"featured_media":30581,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1699],"tags":[84600,84601,84599,84602,84603,84597,84598,84596],"class_list":["post-30580","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-echo-e-in-shell-script","tag-echo-n-in-shell-script","tag-bash-log-command","tag-bash-script-echo-command-line","tag-echo-meaning-in-shell-script","tag-linux-echo-command-output-to-file","tag-linux-echo-to-file","tag-shell-script-output-to-screen"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/30580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=30580"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/30580\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media\/30581"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=30580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=30580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=30580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}