Difference between echo `ls -l` and echo "`ls -l`" ?
Hi guys,
Been messing around with shell programming for a couple of days and I found something that was pretty odd in the behavior of the echo command. Below is an example-:
When I type the following in my /home directory from my lxterminal in Debian-:
echo "`ls -l`"
I get the following output-:
Now this is what I expected. I know whatever is put in ` ` is suppose to interpreted as a command in the BASH echo. So, therefore this is the expected output of ls -l on my /home directory.
But it gets weird when I remove the " " (double quotes) from the echo statement.
When I run the following-:
echo `ls -l`
I get as output the following-:
If you look closely you will see that it is exactly identical to the output that is given above except for the fact that it contains no line breaks. My question is why ?
Why are the line-breaks removed when I remove the double quotes from echo ? Whatever is there in ` `(tild signs) is supposed to be interpreted as a command right ?
If removal of double quotes " " means that there is a change in the meaning of the echo, then please tell me what is the special meaning that double quotes has in echo ?
Is there any difference between echo "$SHELL" and echo $SHELL ? I know the output is same but since one has double quotes and one doesn't is there any difference in the way that BASH treats them internally ?
I am using Debian Wheezy LXDE with Bash 4.2.
Thanks.
Hi,
I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
So in my shell i execute:
{ while true; do echo string; sleep 1; done } | read line This waits one second and returns.
But
{ while true; do /bin/echo string; sleep 1; done } | read line continues to run, and doesn't stop until i kill it explicitly.
I have tried this in bash as well as zsh,... (2 Replies)
Hello All
Nice to meet you all here in this forum,
it's my 1rst time here
i'm asking about a little issue that i face
i added a ksh script that echo " please insert your name " and store the output to a login.log file.
the script is working fine with normal telnet
but Xstart is not working... (8 Replies)
echo `echo ` doesn't echoes anything. And it's logic. But
echo `echo `echo ` ` does echoes "echo". What's the logic of it? the `echo `echo ` inside of the whole (first) echo, echoes nothing, so the first echo have to echo nothing but echoes "echo"
(too much echoing :P):o (2 Replies)
Hello,
On a HP-UX 10.20 server I've executed something similar to this command:
# echo 'selall;info;wait;infolog;view;done' | /usr/sbin/cstm
But it returns sometype of "argument list too long" error.
I suppose there is a way to fix it by using xargs but I can't figure it out.
Any... (7 Replies)
Hello, I have a simple(I think) question!
Although simple, I have been unable to resolve it, so I hope someone can help! OK, here it is:
1)I have an awk script that prints something, such as:
awk '{print $2}' a > x
so x might hold the value of say '10'
2)Now, I just want to check to see if... (4 Replies)
Hi guys,
I have a shell script where I have the following:
for i in ad0 ad1
do
gpart create -s gpt $i || echo "Cannot create GPT partition on "$i". Exiting ..."
gpart add -s 128 -t freebsd-boot $i || echo "Cannot add freebsd-boot partition on "$i". Exiting ..."
gpart add -s 4G -t... (2 Replies)
Hi Folks,
As per the subject, the following command is not working as expected.
echo $variable | mail -s "subject" "xxx@xxx.com"
Could anyone figure it out whats wrong with this. I am using AIX box.
Regards, (2 Replies)
I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here.
I have following script (called out_to_streams.csh):
#!/bin/tcsh -f
echo Redirected to STDOUT > /dev/stdout
echo Redirected to... (2 Replies)
Discussion started by: marcink
2 Replies
LEARN ABOUT PHP
popen
POPEN(3) 1 POPEN(3)popen - Opens process file pointerSYNOPSIS
resource popen (string $command, string $mode)
DESCRIPTION
Opens a pipe to a process executed by forking the command given by $command.
PARAMETERS
o $command
- The command
o $mode
- The mode
RETURN VALUES
Returns a file pointer identical to that returned by fopen(3), except that it is unidirectional (may only be used for reading or writing)
and must be closed with pclose(3). This pointer may be used with fgets(3), fgetss(3), and fwrite(3). When the mode is 'r', the returned
file pointer equals to the STDOUT of the command, when the mode is 'w', the returned file pointer equals to the STDIN of the command.
If an error occurs, returns FALSE.
EXAMPLES
Example #1
popen(3) example
<?php
$handle = popen("/bin/ls", "r");
?>
If the command to be executed could not be found, a valid resource is returned. This may seem odd, but makes sense; it allows you to
access any error message returned by the shell:
Example #2
popen(3) example
<?php
error_reporting(E_ALL);
/* Add redirection so we can get stderr. */
$handle = popen('/path/to/executable 2>&1', 'r');
echo "'$handle'; " . gettype($handle) . "
";
$read = fread($handle, 2096);
echo $read;
pclose($handle);
?>
NOTES
Note
If you're looking for bi-directional support (two-way), use proc_open(3).
Note
When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not
allowed to have .. components in the path to the executable.
Warning
With safe mode enabled, the command string is escaped with escapeshellcmd(3). Thus, echo y | echo x becomes echo y | echo x.
SEE ALSO pclose(3), fopen(3), proc_open(3).
PHP Documentation Group POPEN(3)