LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-05-2008, 08:53 PM   #1
adnankhawer
LQ Newbie
 
Registered: Mar 2008
Location: Pakistan
Distribution: Red Hat, Kubuntu, Suse
Posts: 13

Rep: Reputation: 0
Question Bash builtins??????


Hi,

please tell me the difference b/w

fg %1
bg %1

i know by using command jobs we can see suspended jobs but when i tried by using man bg it only shows that these are bash builtins, please help me out??

Thnks!
 
Old 03-05-2008, 09:22 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
try man bash (use /string to search for "string" then "/" agian to find the next match)

Code:
      bg [jobspec ...]
              Resume each suspended job jobspec in the background, as if it had been started with
              &.   If  jobspec is not present, the shell’s notion of the current job is used.  bg
              jobspec returns 0 unless run when job control is disabled or,  when  run  with  job
              control  enabled,  any  specified  jobspec was not found or was started without job
              control.


       fg [jobspec]
              Resume jobspec in the foreground, and make it the current job.  If jobspec  is  not
              present,  the  shell’s notion of the current job is used.  The return value is that
              of the command placed into the foreground, or failure if run when  job  control  is
              disabled or, when run with job control enabled, if jobspec does not specify a valid
              job or jobspec specifies a job that was started without job control.
 
Old 03-05-2008, 09:23 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
For bash builtins, you can use use "help <command>".
 
Old 03-05-2008, 09:33 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Quote:
Originally Posted by adnankhawer View Post
Hi,

please tell me the difference b/w

fg %1
bg %1

i know by using command jobs we can see suspended jobs but when i tried by using man bg it only shows that these are bash builtins, please help me out??

Thnks!
The man for the bash builtins are part of the bash man page. The bash man page is huge and it is hard to find descriptions for each builtin. One way to search the bash man page is to make it into a txt file and then open that file in a text processor:

man bash > /home/user/mantext/bash.txt

mped /home/user/mantext/bash.txt

(or whatever editor you use)


A better way to make the man pages searchable is to use the lookat program:

http://freshmeat.net/projects/lookat/

Install lookat and then add to following command to /etc/profile, /home/user/.bashrc, and /root/.bashrc

export PAGER=/usr/local/bin/lookat

So using lookat here is what I found in the bash man pages about fg and bg:

Quote:

If the operating system on which bash is running supports job control, bash contains facilities to use it. Typing the suspend character (typically ^Z, Control-Z) while a process is running causes that process to be stopped and returns control to bash. Typing the delayed suspend character (typically ^Y, Control-Y) causes the process to be stopped when it attempts to read input from the terminal, and control to be returned to bash. The user may then manipulate the state of this job, using the bg command to continue it in the background, the fg command to continue it in the foreground, or the kill command to kill it. A ^Z takes effect immediately, and has the additional side effect of causing pending output and typeahead to be discarded.

bg [jobspec ...]
Resume each suspended job jobspec in the background, as if it had been started with &. If jobspec is not present, the shells notion of the current job is used. bg jobspec returns 0 unless run when job control is disabled or, when run with job control enabled, any specified jobspec was not found or was started with out job control.

fg [jobspec]
Resume jobspec in the foreground, and make it the current job. If jobspec is not present, the shell's notion of the current job is used. The return value is that of the command placed into the foreground, or failure if run when job control is disabled or, when run with job control enabled, if jobspec does not specify a valid job or jobspec specifies a job that was started without job control.


---------------------------
Steve Stites

Last edited by jailbait; 03-05-2008 at 09:34 PM.
 
Old 03-06-2008, 08:39 AM   #5
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.

A meta-answer [ as jschiwal wrote earlier, which I just noticed ]: in my version of bash3, there is a built-in help command for built-ins:
Code:
#!/bin/bash3 -

# @(#) s1       Demonstrate help for shell built-ins in bash3.

echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1)

echo
echo " Results of help:"
help bg

exit 0
Producing:
Code:
% ./s1
(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash 3.00.16(1)-release

 Results of help:
bg: bg [job_spec]
    Place JOB_SPEC in the background, as if it had been started with
    `&'.  If JOB_SPEC is not present, the shell's notion of the current
    job is used.
See help help for details ... cheers, makyo

Last edited by makyo; 03-06-2008 at 10:16 AM. Reason: jschiwal wrote in an ealier post.
 
Old 03-06-2008, 09:04 AM   #6
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Quote:
Originally Posted by jailbait View Post
One way to search the bash man page is to make it into a txt file and then open that file in a text processor:
Or use /searchstring in man .. much like in vim, or Firefox, or.. ? My mans (v2.4.3 on Debian Etch and 2.5.1 on Debian Lenny) have that feature.

Last edited by AlucardZero; 03-06-2008 at 09:11 AM.
 
Old 03-06-2008, 10:23 AM   #7
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.
Quote:
Originally Posted by AlucardZero View Post
Or use /searchstring in man ...
It does look like man is doing this, but on the systems I use this is a function of the pager into which man is piping, which often is command less, sometimes more, etc ... cheers, makyo
 
Old 03-06-2008, 10:41 AM   #8
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Quote:
The man for the bash builtins are part of the bash man page. The bash man page is huge and it is hard to find descriptions for each builtin.
For sake of truth, usually man pages are viewed with less, and less does have search feature. Just tap "/", enter search string followed by Enter.

Edit: Late ...

Last edited by Emerson; 03-06-2008 at 10:59 AM.
 
Old 03-07-2008, 02:24 PM   #9
adnankhawer
LQ Newbie
 
Registered: Mar 2008
Location: Pakistan
Distribution: Red Hat, Kubuntu, Suse
Posts: 13

Original Poster
Rep: Reputation: 0
Smile Thanks very much!!

All Dear Fellows,

Thanks for ur help! i really need that....
 
  


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
Bash development - move chmod options to bash jhwilliams Programming 9 06-26-2007 12:13 PM
over rule bash builtins lynnevan Slackware 6 04-01-2007 01:19 PM
Bash Sleep vs crontab and bash serial port nutthick Programming 4 06-01-2006 02:42 AM
Bash: Print usage statement & exit; otherwise continue using Bash shorthand operators stefanlasiewski Programming 9 02-07-2006 05:20 PM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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