Skip to main content

All Questions

Tagged with
81 votes
4 answers
205k views

echo bytes to a file

I'm trying to connect my rasberry Pi to some display using the i2c bus. To get started I wanted to manually write stuff, bytes in particular to a file. How do you write specific bytes to a file? I ...
Mark's user avatar
  • 1,189
34 votes
4 answers
168k views

What is the difference between echo `date`, echo "`date`", and echo '`date`'?

What is the difference between these three commands? echo `date` echo "`date`" echo '`date`' I am confused on what the differences actually are. I think that when the ' are around it means that it ...
John's user avatar
  • 3,639
33 votes
5 answers
145k 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=` ...
user avatar
15 votes
6 answers
9k views

Why there is such a difference in execution time of echo and cat?

Answering this question caused me to ask another question: I thought the following scripts do the same thing and the second one should be much faster, because the first one uses cat that needs to open ...
Mohammad's user avatar
  • 698
14 votes
2 answers
12k views

Is it dangerous to run echo without quotes?

I've seen couple of similar topics, but they are referring to not quoting variables, which I know could lead to unwanted results. I saw this code and was wondering would if it be possible to inject ...
Viktor's user avatar
  • 251
14 votes
2 answers
8k views

Quoted vs unquoted string expansion

for i in $(xrandr); do echo "$i" ; done for i in "$(xrandr)"; do echo "$i"; done for i in "$(xrandr)"; do echo $i; done I understand why 1 differs from 2. But why does 3 give a different output from ...
ManuelSchneid3r's user avatar
13 votes
2 answers
3k views

What is the difference between single quoted $'string' and double quoted $"string" in bash?

I was trying to execute new line using echo and tried following two commands: First command: echo $'Hello World\nThis is a new line' Response: Hello World This is a new line Second command: echo ...
Rafaf Tahsin's user avatar
9 votes
7 answers
19k views

echo \\* - bash backslash escape behavior, is it evaluated backwards?

So in bash, When I do echo \* * This seems right, as * is escaped and taken literally. But I can't understand that, when I do echo \\* \* I thought the first backslash escaped the second one ...
Weishi Z's user avatar
  • 213
8 votes
3 answers
89k views

echo variable with content from command substitution

I wrote a very basic script of command substitution which is below: #!/bin/bash files=$(ls *.fastq); echo $files The directory contains bunch of .fastq file and I just want to use echo command to ...
user3138373's user avatar
  • 2,559
7 votes
2 answers
887 views

Why does dash's echo expand \\\\ differently to bash's echo?

I have a little open source project that for various reasons I've tried to write in reasonably portable shell script. Its automated integration tests check that hostile characters in path expressions ...
csirac2's user avatar
  • 171
6 votes
2 answers
8k views

How do I echo an expression with both single and double quotes?

I have tried many things, but I'm new to the shell. Is it possible to have both double and single quotes within an echo? I want to generate echo "scan 'LPV',{FILTER => "(PrefixFilter ('MP1-Eq1')"}"...
Aashu's user avatar
  • 771
6 votes
2 answers
3k views

What are the effects of double quotes in echo statements? [closed]

When writing a Bash script that contains messages for the user, I can write echo Processing files... or echo "Processing files..." In this and many other cases, the output will be the same....
Chad's user avatar
  • 1,471
5 votes
4 answers
3k views

Echoing something with multiple quotes and key characters (&, $, !, etc.)

Let's say you have to echo this into a file: RZW"a4k6[)b!^"%*X6Evf How do you do it? My actual "line" to echo is a 2048 characters line.
Issam2204's user avatar
  • 105
5 votes
3 answers
17k views

Echo new line and string beginning \t

Sure, echo -e can be used so that \n is understood as a new line. The problem is when I want to echo something beginning with \t e.g. "\test". So let's say I want to perform echo -e "test\n\\test". I ...
Zeruno's user avatar
  • 153
5 votes
2 answers
633 views

Why am I observing different behaviour of echo?

I 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 ronnie@ronnie:~$ So, can someone ...
ronnie's user avatar
  • 901

15 30 50 per page