Basic question on "echo"

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Basic question on "echo"
# 1  
Old 10-12-2016
Basic question on "echo"

what happens when I echo asterisk?


Moderator's Comments:
Mod Comment Please don't hijack other peoples' thread; post our own new one as required by forum rules!

Last edited by RudiC; 10-12-2016 at 02:22 PM.. Reason: Moved the post to new thread.
# 2  
Old 10-12-2016
Code:
echo asterisk
asterisk

These 2 Users Gave Thanks to RudiC For This Post:
# 3  
Old 10-12-2016
If you mean echo *

Then it's actually the shell that's doing it, not echo. It happens before the command is run. * is a wildcard which expands to all files in the current directory. It will happen with any command. It will not necessarily do anything sensible with every command, of course... it just dumps in filenames as arguments.
# 4  
Old 10-13-2016
It should be added that if there are many files in the current directory, then the command to be executed (echo in this case) may be too long and throw an error.
# 5  
Old 10-13-2016
Quote:
Originally Posted by rbatte1
It should be added that if there are many files in the current directory, then the command to be executed (echo in this case) may be too long and throw an error.
In practice, in every POSIX shell echo is a shell builtin, for which this limit does not apply:

Code:
$ echo * | wc -w
  210000
$ /bin/echo * | wc -w
-bash: /bin/echo: Arg list too long
       0

Code:
$ type echo
echo is a shell builtin
$ type /bin/echo
/bin/echo is /bin/echo

This User Gave Thanks to Scrutinizer For This Post:
# 6  
Old 10-13-2016
All of the discussion so far has ignored a couple of other possible problems... The behavior of echo varies from shell to shell and from system to system and even when using the same version of the same shell it may vary when it is installed on different systems whenever the first argument given to echo starts with a hyphen and whenever any argument given to echo contains a backslash character.

We still have no idea whether ithenr00 is asking about the command echo asterisk or echo *. If the latter is the question, then what is it about filename expansion that needs to be explained? And, what files are in the directory where this command is being executed?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

tcsh - understanding difference between "echo string" and "echo string > /dev/stdout"

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

2. AIX

echo $varibla | mail -s "subject" "xxx@xxx.com" not ruuning as expected

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)
Discussion started by: gjarms
2 Replies

3. Shell Programming and Scripting

"Simple" echo/reading variable question...

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)
Discussion started by: astropi
4 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

With that logic this echoes "echo". Question about echo!

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)
Discussion started by: hakermania
2 Replies

6. Shell Programming and Scripting

Very Basic Question regarding "while" loop

Hi, I have a loop like this - while read item do // fire insert query done < itemList.txt The itemList.txt has say, 1000 records. Now what I do is that rhough another program, I make the itemList.txt EMPTY, but still the INSERT query keeps firing the sequence of records. ... (18 Replies)
Discussion started by: angshuman_ag
18 Replies

7. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

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)
Discussion started by: jockey007
7 Replies

8. UNIX for Advanced & Expert Users

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses... Here is the configuration of my system: * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or... (1 Reply)
Discussion started by: talipk
1 Replies

9. UNIX and Linux Applications

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or question of my own) is: Oracle tns listener, "CT_LISTENER", and the enterprise manager (EM) of the instance, which is uniq instance and called... (0 Replies)
Discussion started by: talipk
0 Replies

10. Solaris

question for "echo"

what is the mean: echo -n "^0;!*^G" thanks (3 Replies)
Discussion started by: chris_chang
3 Replies
Login or Register to Ask a Question