LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-11-2009, 04:46 AM   #1
mohit_parihar
LQ Newbie
 
Registered: Nov 2009
Posts: 28

Rep: Reputation: 15
working of bash shell


can any one tell me how does bash help in executing the command echo and kill.how does the shell checks whether the command is builtin command or not. plz tell the complete procedure for both commands.
 
Old 12-11-2009, 04:58 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Without inspecting the bash source code it's hard to know but it probably has a list of its own built-ins and, when it is given a command to execute without a path (without a leading ~, ./ or /) it consults that list.
 
Old 12-11-2009, 05:20 AM   #3
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by mohit_parihar
can any one tell me how does bash help in executing the command echo and kill
Bash shell forks a child process in order to execute any command including 'echo' or 'kill' whatever.

The child process i.e. 'echo' or 'kill' whatever dies automatically when it completes its execution !

I see u are posting all your assignment questions one by one for us to solve ?????????

Last edited by Aquarius_Girl; 12-11-2009 at 05:21 AM.
 
Old 12-11-2009, 05:28 AM   #4
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Try reading this:

http://tldp.org/LDP/abs/html/internal.html
 
Old 12-11-2009, 08:17 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by anishakaul View Post
Bash shell forks a child process in order to execute any command including 'echo' or 'kill' whatever.

The child process i.e. 'echo' or 'kill' whatever dies automatically when it completes its execution !

I see u are posting all your assignment questions one by one for us to solve ?????????
AIUI built-ins do not require fork exec and that is one of the reasons for having built-ins such as echo when perfectly good external commands like /bin/echo already exist. From the link (my emphasis) "A builtin is a command contained within the Bash tool set, literally built in. This is either for performance reasons -- builtins execute faster than external commands, which usually require forking off [1] a separate process"

If these are homework questions (and they could well be) they are unusual ones or strangely re-cast.
 
1 members found this post helpful.
Old 12-12-2009, 02:47 AM   #6
mohit_parihar
LQ Newbie
 
Registered: Nov 2009
Posts: 28

Original Poster
Rep: Reputation: 15
sir actually i m not posting all my assignment here. we were given an assignmment on working of shell. its our intrest to know extra in this field
 
Old 12-12-2009, 03:39 AM   #7
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
then its best to understand the source.
 
0 members found this post helpful.
Old 12-12-2009, 04:05 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by mohit_parihar View Post
sir actually i m not posting all my assignment here. we were given an assignmment on working of shell. its our intrest to know extra in this field
Thanks for the confirmation

I thought as much. Your questions go beyond homework (they would be unfairly hard questions for homework when first learning bash). Nice that you are curious and want to fully understand

Several of your questions relate (indirectly) to *n*x processes. Your curiosity and hunger for deeper understanding would be rewarded by learning about processes. Here are some links. Best to start with the first because it explains processes as seen from the shell that you are already learning about.
 
Old 12-13-2009, 11:47 PM   #9
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by catkin
AIUI built-ins do not require fork exec and that is one of the reasons for having built-ins such as echo when perfectly good external commands like /bin/echo already exist. From the link (my emphasis) "A builtin is a command contained within the Bash tool set, literally built in. This is either for performance reasons -- builtins execute faster than external commands, which usually require forking off [1] a separate process"
thanks for the enlightenment !

Of course, what will be the use of builtin commands if shell still had to fork a process for them ! They are there for the speed !
 
Old 12-14-2009, 03:43 AM   #10
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by anishakaul View Post
thanks for the enlightenment !

Of course, what will be the use of builtin commands if shell still had to fork a process for them ! They are there for the speed !
True -- and some of them because they would not work as external commands, the cd built-in for example. Can you figure out why an external cd command would not work (it's process-related)?
 
1 members found this post helpful.
Old 12-14-2009, 03:49 AM   #11
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by catkin
True -- and some of them because they would not work as external commands, the cd built-in for example. Can you figure out why an external cd command would not work (it's process-related)?
cd cannot work as an external command because an external command creates a child process, and a process cannot affect the environment of its parent (shell in this case).

Last edited by Aquarius_Girl; 12-14-2009 at 05:50 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH SHELL “Shift + Page Up” NOT WORKING r00ster Linux - Newbie 4 09-07-2008 01:33 PM
copy directories and files recursively using C shell or bash shell bostonuser Programming 7 06-06-2008 01:24 AM
Lowercase 'b' not working in bash shell BWebb Linux - Software 1 05-17-2005 04:24 PM
Bash Shell Startup Files - Not working! Carl-Fredrik Linux From Scratch 1 10-20-2004 03:52 PM
bash shell not working? magyartoth Linux - General 4 04-09-2002 08:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:25 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