Questions tagged [echo]

echo is a common command to print a message onto an output device, like a display

116 questions
61
votes
2 answers

Path Environment Variable Windows 10. Echo %Path% on command prompt shows only %Path%

My variable value in path is as follows C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Program…
Arun S
  • 719
  • 1
  • 5
  • 3
41
votes
3 answers

equivalent "echo on" for linux?

How can I get to stdout all commands that run in bash script? That is output must contain commands output AND commands themselves. I found #!/bin/bash -x but this is not exactly the same because instead of mysql -v dbname < dump.sql | grep…
Putnik
  • 912
  • 1
  • 6
  • 16
37
votes
2 answers

What is wrong with “echo $(stuff)” or “echo `stuff`”?

I used one of the following echo $(stuff) echo `stuff` (where stuff is e.g. pwd or date or something more complicated). Then I was told this syntax is wrong, bad practice, non-elegant, excessive, redundant, overly complicated, cargo cult…
Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
34
votes
1 answer

how to escape pipe symbol | in bat scripts?

I need to echo commad usage like this in batch script named command.bat command.bat on|off I cant use echo %0 on|off I know I can use echo "%0 on|off" but it puts quotes along Is there any other way?
Prashant Bhate
  • 985
  • 2
  • 9
  • 12
32
votes
2 answers

Shell script echo new line to file

I want to echo a new line to a file in between variables in a shell script. Here's my code: var1="Hello" var2="World!" logwrite="$var1 [Here's where I want to insert a new line] $var2 echo "$logwrite" >> /Users/username/Desktop/user.txt Right…
daviesgeek
  • 1,619
  • 7
  • 22
  • 34
27
votes
2 answers

How do I restore input echoing in the terminal?

Sometimes when a script gets killed at a password prompt, I can no longer see my input being echoed in the terminal. That is, normally at a terminal, I see this: $ _ $ foobar_ But in this case, I don't see what I've…
congusbongus
  • 805
  • 1
  • 10
  • 13
23
votes
2 answers

Why use echo before installing new software?

I am new to the computing world. While installing ROS Indigo, the first step directs me to use the following code: sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' Why do…
Pallav Bakshi
  • 351
  • 4
  • 9
22
votes
1 answer

Why does `echo -e "\\\SOME_TEXT"` show only one backslash?

Could some one explain what is happening behind the scenes in character escaping in Linux shell? I tried the following and googled a lot, without any success in understanding what (and how) is going on: root@sv01:~# echo -e "\ Hello!" \…
Mohammed Noureldin
  • 1,285
  • 2
  • 19
  • 29
18
votes
3 answers

How to print new line character with echo?

I dump a string with hexdump like this 2031 3334 2e30 0a32 2032 3331 302e 000a. It is clear that 0x0a is new line character, however, when I try to echo this string out, I always got 1 430.2 2 13.0 -- the new line is replaced with a space, even I…
Summer_More_More_Tea
  • 983
  • 6
  • 14
  • 28
17
votes
7 answers

Cat command and echo

I'd like to concatenate the output from echo with content of a file. I've tried the following comand: echo "abc" | cat 1.txt > 2.txt but the 2.txt file only contains the content from 1.txt. Why doesn't it work?
Ringger81
  • 1,097
  • 3
  • 11
  • 22
16
votes
3 answers

Change encoding of txt file

When I write : file file1.txt I have this output : Little-endian UTF-16 Unicode text, with CR line terminators Then if I write : file file2.txt I have : ASCII text file2.txt is created by making : echo $var > "file2.txt" I would like…
Pierre
  • 307
  • 2
  • 3
  • 7
16
votes
4 answers

How do I create a multiline text file with Echo in Windows command prompt?

I'm using Windows 7 and I would like to quickly create a small text file with a few lines of text in the Command prompt. I can create a single line text file with: echo hello > myfile.txt but how can I create a text file with multiple lines using…
Jonas
  • 26,874
  • 52
  • 105
  • 125
15
votes
3 answers

Why does bash need && to echo a variable on one line?

Why does SOMETHING=1 && echo $SOMETHING need && to return 1 Why doesn't SOMETHING=1 echo $SOMETHING return 1
Joel
  • 261
  • 2
  • 6
13
votes
3 answers

On a Linux shell, what is echo $1 supposed to do?

I do a echo $1, it prints out what is the default login shell used. But for echo $2 onwards, all I get is a newline. Why is that?
Lazer
  • 17,227
  • 43
  • 116
  • 141
9
votes
4 answers

SSH: How to change value in config file in one command

How can I change the value of, let's say, PasswordAuthentication in /etc/ssh/sshd_config in commands? As well, remove a # in front of the "key" I wish to value. These don't all have to be in one command. I setup quite a few servers, and remembering…
Nahydrin
  • 415
  • 2
  • 5
  • 12
1
2 3 4 5 6 7 8