Questions tagged [echo]

Simple function outputting text. Exists in script languages.

echo is mainly used in batch (cmd). An example would be:

echo hello world

which prints "hello world" to the terminal.

The output by default prints directly to the command line, however, it may be piped into a following command as an input. This can be very handy and allows for interoperability between different processes/languages.

5742 questions
67
votes
6 answers

How to avoid echo closing FIFO named pipes? - Funny behavior of Unix FIFOs

I want to output some data to a pipe and have the other process do something to the data line by line. Here is a toy example: mkfifo pipe cat pipe& cat >pipe Now I can enter whatever I want, and after pressing enter I immediately see the same line.…
user1084871
  • 1,012
  • 1
  • 10
  • 12
64
votes
7 answers

UNIX, get environment variable

I have a ridiculous question due to a ridiculous problem. Normally if I want to get the contents of an environment variable in a UNIX shell, I can do echo ${VAR} Let's assume, due to my ridiculous situation, that this isn't possible. How do I get…
Mike
  • 58,961
  • 76
  • 175
  • 221
61
votes
5 answers

How to clear previously echoed items in PHP

In php, is there any way to clear/remove all previously echoed or printed items? For example:
edt
  • 22,010
  • 30
  • 83
  • 118
59
votes
5 answers

How do I append the UNIX command date to an echo statement

Basically I want to have the terminal output a message followed by the date and time, like "Hi, today is -dateandtime-". So echo can accomplish the first bit, and date can accomplish the last, but only separately, how can I put them together (in one…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
55
votes
7 answers

PHP to search within txt file and echo the whole line

Using php, I'm trying to create a script which will search within a text file and grab that entire line and echo it. I have a text file (.txt) titled "numorder.txt" and within that text file, there are several lines of data, with new lines coming in…
aullah
  • 1,334
  • 3
  • 20
  • 28
54
votes
13 answers

What is the difference between PHP echo and PHP return in plain English?

Yes, I have googled this question and even referred to my textbook (PHP by Don Gosselin) but I seriously can't seem to understand the explanation. From my understanding: echo = shows the final result of a function return = returns the value from a…
Joe Morales
  • 891
  • 2
  • 12
  • 20
54
votes
2 answers

Echo curl request header & body without sending it?

With the curl command line tool, is it possible to echo, print, or view the request, and not send it? Sort of like a -n option? I would like to see the request header & body, and anything else that's included. Is there anything else that's sent…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
52
votes
13 answers

How do you strip quotes out of an ECHO'ed string in a Windows batch file?

I have a Windows batch file I'm creating, but I have to ECHO a large complex string, so I'm having to put double quotes on either end. The problem is that the quotes are also being ECHOed to the file I'm writing it to. How do you ECHO a string…
Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
50
votes
6 answers

bash prompt and echoing colors inside a function

I have this in my .bashrc: LIGHTGREEN="\[\033[1;32m\]" LIGHTRED="\[\033[1;31m\]" WHITE="\[\033[0;37m\]" RESET="\[\033[0;00m\]" function error_test { if [[ $? = "0" ]]; then echo -e "$LIGHTGREEN" else echo -e "$LIGHTRED" …
Andy Ray
  • 30,372
  • 14
  • 101
  • 138
47
votes
3 answers

Bash: Echoing a echo command with a variable in bash

Ok, here is one I am struggling with as we speak. Echoing a echo command with a variable. echo "creating new script file." echo "#!/bin/bash" > $servsfile echo "read -p "Please enter a service: " ser " >> $servfile echo "servicetest=`getsebool -a |…
David
  • 891
  • 1
  • 8
  • 18
46
votes
10 answers

php - insert a variable in an echo string

$i = 1 echo '

' ++i Trying to insert a variable into an echoed string. The above code doesn't work. How do I iterate a php variable into an echo string?
Anthony Miller
  • 15,101
  • 28
  • 69
  • 98
45
votes
2 answers

Simplest way to display current month and year like "Aug 2016" in PHP?

What is the shortest, simplest code to generate the curent month in Full English like September or in abbreviated three letter version like Feb and then add the current Year 2011? So the code will, depending on the month and year, echo things…
Sam
  • 15,254
  • 25
  • 90
  • 145
44
votes
4 answers

PHP printed boolean value is empty, why?

I am new to PHP. I am implementing a script and I am puzzled by the following: $local_rate_filename = $_SERVER['DOCUMENT_ROOT']."/ghjr324l.txt"; $local_rates_file_exists = file_exists($local_rate_filename); echo…
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
44
votes
8 answers

How do I use variables in single quoted strings?

How do I echo a variable inside single quotes? echo 'test text "here_is_some_test_text_$counter" "output"' >> ${FILE}
Pectus Excavatum
  • 3,593
  • 16
  • 47
  • 68
42
votes
2 answers

How in Ant output values of properties?

With ant there exists the echo markup: but it seems useless. I need to check values in an ant script, e.g. but it only yields: [echo]…
user810430
  • 11,181
  • 15
  • 38
  • 43