LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-15-2009, 06:11 AM   #1
shuchi
LQ Newbie
 
Registered: Apr 2009
Posts: 9

Rep: Reputation: 0
Unhappy more information about echo command


can anyone tell me how does echo command work internally?
can echo command used for purpose other then display message, colour and effects?
 
Old 04-15-2009, 06:19 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
What is the context of this question?

First, look at the man page ("man echo"). I doubt if the command does anything more than what it says there......

As for the internals, you may need to look at the source code. Quick Google says echo is a built-in, so you'll need the BASH source code.
 
Old 04-15-2009, 06:25 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
echo is also an external command coming from coreutils. The code is derived from the bash source code. Maybe the coreutils' one is more readable, being in a stand-alone C file.
 
Old 04-16-2009, 05:21 AM   #4
shuchi
LQ Newbie
 
Registered: Apr 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Smile

ofcourse echo can do other things as i said can change the colour of foreground and background and also can set some effetcs, echo can create a file.
and now i wannna know can echo display the access time of a file, if yes then how?
 
Old 04-16-2009, 05:27 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by shuchi View Post
ofcourse echo can do other things as i said can change the colour of foreground and background and also can set some effetcs,
Ummm ... nope, that's the terminal. Echo just tells it
to do so.

Quote:
Originally Posted by shuchi View Post
echo can create a file.
Nope - that's the shell.

Quote:
Originally Posted by shuchi View Post
and now i wannna know can echo display the access time of a file, if yes then how?
No.


Cheers,
Tink
 
Old 04-16-2009, 08:56 AM   #6
shuchi
LQ Newbie
 
Registered: Apr 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Red face echo with wc

when i type the following command
echo *|wc
the output will be- 1 25 55
here i know what is 25(no of files in current directory), but what are 1 and 55 for?




plz tell me if anyone knows..........
waiting for reply...
thankyou!
 
Old 04-16-2009, 09:18 AM   #7
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by shuchi View Post
when i type the following command
echo *|wc
the output will be- 1 25 55
here i know what is 25(no of files in current directory), but what are 1 and 55 for?




plz tell me if anyone knows..........
waiting for reply...
thankyou!
Please read the first line of the wc man page. It is there, as clear as day.
 
Old 04-16-2009, 11:08 AM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
First look at the output echo *, then try to figure out what those numbers mean after having read the man page as suggested by pwc101. This is a general advice: carefully read the man pages! Most of the answers are there.
 
Old 04-17-2009, 10:34 PM   #9
shuchi
LQ Newbie
 
Registered: Apr 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Wink echo wid $

thankyou for ur useful suggestion.
now following are some combinations with echo and their outputs, i jst tried randomly, plz tell me what the output are abt........

1. # echo $-
himBH

2. #echo $!
2983
(this is not a PID)

3. #echo $&
[1]20662
[root@localhost~]#$
date;pwd
sat apr.............. 2009
[1]+Done echo $
/root


let me know what's d significance of $ sign?




Quote:
Originally Posted by colucix View Post
First look at the output echo *, then try to figure out what those numbers mean after having read the man page as suggested by pwc101. This is a general advice: carefully read the man pages! Most of the answers are there.
 
Old 04-18-2009, 06:15 AM   #10
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can find all the answers here. You should really read a shell programming guide, where you can find all the proper answers to your basic questions. Have a nice time!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
echo: command or built-in? colucix Linux - General 5 01-06-2008 11:55 AM
How to echo/tail process information davimint Linux - Newbie 1 12-15-2006 02:04 PM
echo command s_hcl Linux - General 1 09-06-2006 05:27 AM
what is the echo command in perl? hamish Programming 5 12-14-2004 08:31 AM
echo command peculiarity eallen Linux - General 3 02-11-2003 05:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration