Questions tagged [echo]

Simple function outputting text. Exists in script languages.

echo is mainly used in batch (cmd) an example of these would be:

echo hello world
5448 questions
2791
votes
23 answers

Echo newline in Bash prints literal \n

In Bash, tried this: echo -e "Hello,\nWorld!" But it doesn't print a newline, only \n. How can I make it print the newline? I'm using Ubuntu 11.04 (Natty Narwhal).
Sergey
  • 39,828
  • 24
  • 80
  • 122
2098
votes
31 answers

How to change the output color of echo in Linux

I am trying to print a text in the terminal using echo command. I want to print the text in a red color. How can I do that?
satheesh.droid
  • 24,169
  • 8
  • 32
  • 33
498
votes
11 answers

Multi-line string with extra space (preserved indentation)

I want to write some pre-defined texts to a file with the following: text="this is line one\n this is line two\n this is line three" echo -e $text > filename I'm expecting something like this: this is line one this is line two this is line…
cizixs
  • 9,843
  • 5
  • 43
  • 58
357
votes
10 answers

Echo tab characters in bash script

How do I echo one or more tab characters using a bash script? When I run this code res=' 'x # res = "\t\tx" echo '['$res']' # expect [\t\tx] I get this res=[ x] # that is [x]
kalyanji
  • 3,748
  • 2
  • 15
  • 6
327
votes
8 answers

How can I suppress all output from a command using Bash?

I have a Bash script that runs a program with parameters. That program outputs some status (doing this, doing that...). There isn't any option for this program to be quiet. How can I prevent the script from displaying anything? I am looking for…
6bytes
  • 5,278
  • 7
  • 36
  • 38
283
votes
5 answers

How does one output bold text in Bash?

I'm writing a Bash script that prints some text to the screen: echo "Some Text" Can I format the text? I would like to make it bold.
JamesRat
  • 2,990
  • 2
  • 14
  • 15
276
votes
33 answers

How can I repeat a character in Bash?

How could I do this with echo? perl -E 'say "=" x 100'
sid_com
  • 21,289
  • 23
  • 89
  • 171
222
votes
5 answers

How are echo and print different in PHP?

Possible Duplicate: Reference: Comparing PHP's print and echo Is there any major and fundamental difference between these two functions in PHP?
zuk1
  • 16,451
  • 21
  • 56
  • 62
184
votes
2 answers

Reference: Comparing PHP's print and echo

What is the difference between PHP's print and echo? Stack Overflow has many questions asking about PHP's print and echo keyword usage. The purpose of this post is to provide a canonical reference question and answer about PHP's print and echo…
user187291
  • 50,823
  • 18
  • 89
  • 127
168
votes
4 answers

Why does 1...1 evaluate to 10.1?

I've just faced a little PHP snippet from 3v4l: https://3v4l.org/jmrZB echo 1...1; //10.1 And I'm afraid I have no idea how to explain its results. Why is this considered valid at all?
Gino Pane
  • 4,179
  • 2
  • 25
  • 41
161
votes
3 answers

Echo a blank (empty) line to the console from a Windows batch file

When outputting status messages to the console from a Windows batch file, I want to output blank lines to break up the output. How do I do this?
DavidRR
  • 15,000
  • 17
  • 89
  • 169
128
votes
13 answers

How can I echo HTML in PHP?

I want to conditionally output HTML to generate a page, so what's the easiest way to echo multiline snippets of HTML in PHP 4+? Would I need to use a template framework like Smarty? echo '', "\n"; // I'm sure there's a better way! echo…
Robin Rodricks
  • 99,791
  • 133
  • 372
  • 575
111
votes
2 answers

How to use shell commands in Makefile

I'm trying to use the result of ls in other commands (e.g. echo, rsync): all: FILES = $(shell ls) echo $(FILES) But I get: make FILES = Makefile file1.tgz file2.tgz…
Adam Matan
  • 107,447
  • 124
  • 346
  • 512
96
votes
9 answers

Why can't I specify an environment variable and echo it in the same command line?

Consider this snippet: $ SOMEVAR=AAA $ echo zzz $SOMEVAR zzz zzz AAA zzz Here I've set $SOMEVAR to AAA on the first line - and when I echo it on the second line, I get the AAA contents as expected. But then, if I try to specify the variable on…
sdaau
  • 32,015
  • 34
  • 178
  • 244
91
votes
9 answers

How can I align the columns of tables in Bash?

I'd like to output a table format text. What I tried to do was echo the elements of an array with '\t', but it was misaligned. My code for((i=0;i
user1709294
  • 1,285
  • 4
  • 15
  • 20
1
2 3
99 100