{"id":4883,"date":"2021-07-14T00:58:29","date_gmt":"2021-07-14T03:58:29","guid":{"rendered":"https:\/\/bureau-it.com\/artigos\/using-echo\/"},"modified":"2024-09-19T22:34:31","modified_gmt":"2024-09-20T01:34:31","slug":"using-echo","status":"publish","type":"post","link":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/","title":{"rendered":"Using echo"},"content":{"rendered":"\n

man<\/code> is very direct in saying that the echo<\/code> command is used to repeat arguments to std out.\nAnd that means passing practically anything to standard output.\nWith echo we can use escape characters, such as tabulation, new line, activate text colors, background, character decoration,<\/a> etc. <\/p>\n\n

Escape<\/h2>\n\n

Without -e<\/strong>, it can’t interpret escaped commands.<\/p>\n\n

$ echo \"Oi\\nEu sou o Echo.\"\nOi\\nEu sou o Echo.<\/pre>\n\n

With -e<\/strong>, you enable the interpretation of escaped characters, such as \\n to skip lines:<\/p>\n\n

$ echo -e \"Oi\\nEu sou o Echo.\"\nOi\nEu sou o Echo.<\/pre>\n\n

For a new column ,<\/strong> use the -e<\/strong> option with \\v<\/strong>:<\/p>\n\n

$ Nome=\"Echo\"\n$ echo -e \"Oi\\nSeu nome \u00e9 $Nome \\v$Nome \\v$Nome\"\nOi\nSeu nome \u00e9 Echo\n                  Echo\n                         Echo<\/pre>\n\n

To re-tab use the -e<\/strong> option with \\t<\/strong>:<\/p>\n\n

$ echo -e \"\\tOl\u00e1,\\n\\tEste \u00e9 um texto tabulado.\"\n    Ol\u00e1,\n    Este \u00e9 um texto tabulado.<\/pre>\n\n

Avoid newline<\/h2>\n\n

If you don’t set the -n option, the information will be displayed on the screen, then a new line will appear:<\/p>\n\n

$ echo \"Oi, digite seu nome: \"; read nome\nOi, digite seu nome: \n_<\/pre>\n\n

Now, with -n, we no longer have a newline<\/em> after the sentence:<\/p>\n\n

$ echo -n \"Oi, digite seu nome: \"; read nome\nOi, digite seu nome: _ <\/pre>\n\n

This new line that echo<\/code> creates can get in the way when it comes to getting the hexadecimal of a character<\/p>\n\n

$ echo -e A |hexdump\n0000000 41 0a <----- olha o newline aqui no 0a, atrapalhando\n0000002\n\n$ echo -en A |hexdump\n0000000 41 <----- agora, s\u00f3 o hex 41, que \u00e9 o A em ascii\n0000001<\/pre>\n\n

Do you have any suggestions on how to use echo?\nSend it to me in the comments and I’ll insert it here =D <\/p>\n","protected":false},"excerpt":{"rendered":"

A quick guide on how to use the echo command in the most practical way possible.<\/p>\n","protected":false},"author":2,"featured_media":4621,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"resumo_insta":"","imagem_insta":"","acessibilidade_insta":"","hashtags_insta":"","resumo_linkedin":"","imagem_linkedin":"","hashtag_linkedin":"","resumo_face":"","imagem_face":"","hashtag_face":"","footnotes":""},"categories":[96],"tags":[98],"class_list":["post-4883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shell-script-en","tag-echo-en"],"yoast_head":"\nUsing echo - bureau-it.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using echo - bureau-it.com\" \/>\n<meta property=\"og:description\" content=\"A quick guide on how to use the echo command in the most practical way possible.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/\" \/>\n<meta property=\"og:site_name\" content=\"bureau-it.com\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-14T03:58:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-20T01:34:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"541\" \/>\n\t<meta property=\"og:image:height\" content=\"279\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Daniel Cambr\u00eda\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Cambr\u00eda\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"NewsArticle\"],\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/\"},\"author\":{\"name\":\"Daniel Cambr\u00eda\",\"@id\":\"https:\/\/bureau-it.com\/en\/#\/schema\/person\/c329412c3ef15c08d403bf4835dca2a5\"},\"headline\":\"Using echo\",\"datePublished\":\"2021-07-14T03:58:29+00:00\",\"dateModified\":\"2024-09-20T01:34:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/\"},\"wordCount\":168,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/bureau-it.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png\",\"keywords\":[\"echo\"],\"articleSection\":[\"shell script\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#respond\"]}],\"copyrightYear\":\"2021\",\"copyrightHolder\":{\"@id\":\"https:\/\/bureau-it.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/\",\"url\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/\",\"name\":\"Using echo - bureau-it.com\",\"isPartOf\":{\"@id\":\"https:\/\/bureau-it.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png\",\"datePublished\":\"2021-07-14T03:58:29+00:00\",\"dateModified\":\"2024-09-20T01:34:31+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#primaryimage\",\"url\":\"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png\",\"contentUrl\":\"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png\",\"width\":541,\"height\":279},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/bureau-it.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using echo\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/bureau-it.com\/en\/#website\",\"url\":\"https:\/\/bureau-it.com\/en\/\",\"name\":\"bureau-it.com\",\"description\":\"Bureau IT | Bureau de Tecnologia\",\"publisher\":{\"@id\":\"https:\/\/bureau-it.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/bureau-it.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/bureau-it.com\/en\/#organization\",\"name\":\"Bureau IT\",\"alternateName\":\"Bureau de Tecnologia\",\"url\":\"https:\/\/bureau-it.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bureau-it.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/bureau-it.com__icone-bbk-abk-itgreen-1.png\",\"contentUrl\":\"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/bureau-it.com__icone-bbk-abk-itgreen-1.png\",\"width\":496,\"height\":497,\"caption\":\"Bureau IT\"},\"image\":{\"@id\":\"https:\/\/bureau-it.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/bureau-it\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/bureau-it.com\/en\/#\/schema\/person\/c329412c3ef15c08d403bf4835dca2a5\",\"name\":\"Daniel Cambr\u00eda\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bureau-it.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/bureau-it.com\/wp-content\/uploads\/2024\/11\/cropped-dani-43-96x96.jpeg\",\"contentUrl\":\"https:\/\/bureau-it.com\/wp-content\/uploads\/2024\/11\/cropped-dani-43-96x96.jpeg\",\"caption\":\"Daniel Cambr\u00eda\"},\"description\":\"CEO e CTO do Bureau IT, come\u00e7ou na tecnologia aos 13 anos e vem de uma fam\u00edlia empreendedora. Com experi\u00eancia t\u00e9cnica e de gest\u00e3o, dedica-se \u00e0 m\u00fasica nas horas vagas e cuida de seus cinco gatos, unindo tecnologia, arte e boas companhias.\",\"url\":\"https:\/\/bureau-it.com\/en\/artigos\/author\/daniel-cambria\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using echo - bureau-it.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/","og_locale":"en_US","og_type":"article","og_title":"Using echo - bureau-it.com","og_description":"A quick guide on how to use the echo command in the most practical way possible.","og_url":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/","og_site_name":"bureau-it.com","article_published_time":"2021-07-14T03:58:29+00:00","article_modified_time":"2024-09-20T01:34:31+00:00","og_image":[{"width":541,"height":279,"url":"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png","type":"image\/png"}],"author":"Daniel Cambr\u00eda","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Daniel Cambr\u00eda","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","NewsArticle"],"@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#article","isPartOf":{"@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/"},"author":{"name":"Daniel Cambr\u00eda","@id":"https:\/\/bureau-it.com\/en\/#\/schema\/person\/c329412c3ef15c08d403bf4835dca2a5"},"headline":"Using echo","datePublished":"2021-07-14T03:58:29+00:00","dateModified":"2024-09-20T01:34:31+00:00","mainEntityOfPage":{"@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/"},"wordCount":168,"commentCount":0,"publisher":{"@id":"https:\/\/bureau-it.com\/en\/#organization"},"image":{"@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#primaryimage"},"thumbnailUrl":"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png","keywords":["echo"],"articleSection":["shell script"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#respond"]}],"copyrightYear":"2021","copyrightHolder":{"@id":"https:\/\/bureau-it.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/","url":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/","name":"Using echo - bureau-it.com","isPartOf":{"@id":"https:\/\/bureau-it.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#primaryimage"},"image":{"@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#primaryimage"},"thumbnailUrl":"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png","datePublished":"2021-07-14T03:58:29+00:00","dateModified":"2024-09-20T01:34:31+00:00","breadcrumb":{"@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bureau-it.com\/en\/artigos\/using-echo\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#primaryimage","url":"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png","contentUrl":"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/echo.png","width":541,"height":279},{"@type":"BreadcrumbList","@id":"https:\/\/bureau-it.com\/en\/artigos\/using-echo\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/bureau-it.com\/en\/"},{"@type":"ListItem","position":2,"name":"Using echo"}]},{"@type":"WebSite","@id":"https:\/\/bureau-it.com\/en\/#website","url":"https:\/\/bureau-it.com\/en\/","name":"bureau-it.com","description":"Bureau IT | Bureau de Tecnologia","publisher":{"@id":"https:\/\/bureau-it.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bureau-it.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/bureau-it.com\/en\/#organization","name":"Bureau IT","alternateName":"Bureau de Tecnologia","url":"https:\/\/bureau-it.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bureau-it.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/bureau-it.com__icone-bbk-abk-itgreen-1.png","contentUrl":"https:\/\/bureau-it.com\/wp-content\/uploads\/2021\/07\/bureau-it.com__icone-bbk-abk-itgreen-1.png","width":496,"height":497,"caption":"Bureau IT"},"image":{"@id":"https:\/\/bureau-it.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/company\/bureau-it\/"]},{"@type":"Person","@id":"https:\/\/bureau-it.com\/en\/#\/schema\/person\/c329412c3ef15c08d403bf4835dca2a5","name":"Daniel Cambr\u00eda","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bureau-it.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/bureau-it.com\/wp-content\/uploads\/2024\/11\/cropped-dani-43-96x96.jpeg","contentUrl":"https:\/\/bureau-it.com\/wp-content\/uploads\/2024\/11\/cropped-dani-43-96x96.jpeg","caption":"Daniel Cambr\u00eda"},"description":"CEO e CTO do Bureau IT, come\u00e7ou na tecnologia aos 13 anos e vem de uma fam\u00edlia empreendedora. Com experi\u00eancia t\u00e9cnica e de gest\u00e3o, dedica-se \u00e0 m\u00fasica nas horas vagas e cuida de seus cinco gatos, unindo tecnologia, arte e boas companhias.","url":"https:\/\/bureau-it.com\/en\/artigos\/author\/daniel-cambria\/"}]}},"_links":{"self":[{"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/posts\/4883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/comments?post=4883"}],"version-history":[{"count":0,"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/posts\/4883\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/media\/4621"}],"wp:attachment":[{"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/media?parent=4883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/categories?post=4883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bureau-it.com\/en\/wp-json\/wp\/v2\/tags?post=4883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}