The echo tag has no wiki summary.
1
vote
2answers
57 views
How to make sure the shell builtin echo is invoked so that its not visible in process list?
Is this going to be visible in the process listing if the below line is executed from a command line or a shell script
bash -c "echo $password"
or
i just need to do echo $password from within ...
0
votes
2answers
72 views
Supress expansion of * in echo
I am working on a script which dynamically executes some queries on daily basis. These queries are coming from a table in the database.
Here is the sample output of the query table:
...
0
votes
1answer
49 views
the use for echo without argument in shell scripting
I have a following bash script I encountered on the web that prints the power set of a given lines of elements.
p() { [ $# -eq 0 ] && echo || (shift; p "$@") |
while read r ; do echo ...
1
vote
1answer
123 views
How to put value of echo pipe netcat commands into variable [duplicate]
I have this command succession:
echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567
and let's say it return a string like, for example "Hello...bla".
(on the 89.196.167.2 i have made a server ...
3
votes
2answers
157 views
echo string >> file does not work
I wrote the following script:
for filename in `find . -name '*'.cpp | grep $IN_REGEX | grep -v $OUT_REGEX`
do
echo "Output file is $OUTPUT_FILE"
count=`git log --pretty=format: --name-only ...
78
votes
5answers
20k views
Why is printf better than echo?
I have heard that printf is better than echo and I can recall only one instance from my experience where I had to use printf because echo didn't work for feeding some text into some program on RHEL ...
1
vote
3answers
133 views
How to stop `grep` from truncating pipe output
Is there any way to have an echo at the end of a pipe simply append to the current output rather than removing it all? For example, how can I keep the output for my cat and grep and add "END OF ...
-4
votes
2answers
124 views
Redirecting the content of a file to the command “echo”
I have a file named my_file.txt whose content is just the string Hello. How could I redirect its content to the command echo?
I know I have the commands less, cat, more... but I need to do it with ...
1
vote
3answers
823 views
How do I set an environment variable on the command line and have it appear in commands?
If I run
export TEST=foo
echo $TEST
It outputs foo.
If I run
TEST=foo echo $TEST
It does not. How can I get this functionality without using export or a script?
2
votes
1answer
104 views
My echo command doesn't accept switches (echo -n or echo -e)
I have an echo statement in my script as below:
echo -ne "Check Script";
I was expecting it to print
Check Script
but I am getting the below output
-ne Check Script
But when I run the same ...
3
votes
1answer
131 views
Printing colored text using script
When I type below command in the shell I get the OUTPUT in green color.
Command
echo "\033[32mCONNECTING TO abpwrk\033[m";
Output(in green color)
CONNECTING TO abpwrk
But if I use the same ...
4
votes
2answers
136 views
Why am I observing different behaviour of echo?
I am a bash beginner and observed the below behavior of echo
#!/bin/bash
x=" hello"
echo $x
echo "$x"
Now when I run the above code I get
ronnie@ronnie:~$ bash test.sh
hello
hello
...
6
votes
1answer
238 views
Append same text to many files using cat or echo?
How can I write the same content to many text files by using cat or echo in only one command?
For example I want to write "hello" to file1 and file2. I tried:
echo "hello" >> file1 file2
...
4
votes
3answers
266 views
Construct a command by putting a string into a tty
I managed to do this
echo -n "command" > /dev/tty1
The letters appear, and the cursor moves, but they are "ghosts" - if you hit enter, nothing happens (they are not in stdin).
Edit:
In the ...
20
votes
1answer
660 views
Why does echo >file use more real time than echo | sed >file?
The example, below, surprised me. It seems to be counter intuitive... aside from the fact that there is a whisker more user time for the echo | sed combo.
Why is echo using so much sys time when it ...
6
votes
2answers
643 views
Using sed to color the output from a command on solaris
I have a ksh script that must work on both linux and solaris. I'm trying to color the output of specific commands. It works on linux (specifically RHEL6), but not on solaris (SunOS 5.10).
Command ...
6
votes
4answers
2k views
printing colored text using echo
I know that for printing a colored text using echo, for example red color, the code is: echo -e "\e[1;31m This is red text \e[0m"
and I know that in this example, 31 is code of red color and the ...
5
votes
2answers
1k views
Unexpected results testing serial loopback using echo and cat
So I have a standard RS232 serial port that is looped back to itself by simply running a wire from Tx to Rx. I'm testing loopback by running echo and cat in two separate terminals:
cat /dev/ttyS1
...
6
votes
1answer
227 views
differences between echo“”> and > command
I am new to Linux. There is something that is unclear to me.
What is the difference between echo "" > logfile and > logfile ?
When I run the first one, the logfile size doesn't become zero ...
1
vote
2answers
1k views
How can I trim the carriage return from text that is being piped in bash?
I'm using this command to get my last typed command:
history | cut -c 8- | tail -n 2 | head -n 1
It works very well in bash, removing the line numbers, but there is one problem I have with it, (er, ...
5
votes
4answers
1k views
How can I create a file with multiple lines from the command-line?
How can I enter the following contents in a file:
Hi
abcd
I tried using echo "Hi\nabcd" >> ab.txt, but in the file it's written as is (the \n is included, instead of a newline)
3
votes
1answer
269 views
Shell script doesn't paint last line of stdout to screen without user input
I have a shell script that's happily doing all my backup process and writing progress to stderr and stdout, with one exception — the last line doesn't get written to my terminal (if I call the script ...
1
vote
2answers
479 views
Alias Loop in csh
Why is there an Alias loop error created here:
alias df 'printf "\n"; df -hP | column -t'
But not here:
alias df 'df -hP | column -t'
I realize I could call the alias something else and still ...
13
votes
4answers
3k views
How to delete line with echo?
I know that I could delete the last three chars with:
echo -ne '\b\b\b'
But how can I delete a full line? I mean I dont want to use:
echo -ne ...
2
votes
1answer
73 views
Why doesn't text piped into an echo get outputted?
Why doesn't this command output "1"?
echo 1 | echo
I imagine it working this way:
1. echo 1 (outputs 1)
2. | echo (takes the 1 as an input, then echos it)
Isn't this what should happen?
3
votes
3answers
2k views
Why is echo ignoring my quote characters?
The echo command isn't including the complete text that I give it. For example, if I do:
$ echo ' echo PARAM=` grep $ARG /var/tmp/setfile | awk '{print $2}' ` '
It outputs:
echo PARAM=` ...
1
vote
2answers
272 views
How can I right-justify variable length output?
So I don't want this:
echo "9"
9
Rather I need this, with e.g.: 4 spaces before it:
MAGICK "9"
9
So if I try it with 10:
MAGICK "10"
10
then it will just have 3 spaces before it. How ...
-1
votes
2answers
333 views
Copying a few lines from stdout to stderr - but only if stderr is different from stdout
I have a bash script "backup.sh", which prints out everything to stdout, including all the files that are transferred during backup.
I'd like to make it possible to keep that full output, but when ...
3
votes
2answers
265 views
Weird output by echo
I was playing with echo $$ a while back. Well that displays that pid of the shell. But then I did echo ! which promptly displayed !. Then echo !! produced
echo echo !
echo !
$echo !!! gave
echo ...
16
votes
4answers
2k views
How to echo a bang!
I tried to create a script by echo'ing the contents into a file, instead of opening it with a editor
echo -e "#!/bin/bash \n /usr/bin/command args" > .scripts/command
The output:
bash: ...

