LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Bash builtins?????? (https://www.linuxquestions.org/questions/linux-software-2/bash-builtins-626024/)

adnankhawer 03-05-2008 08:53 PM

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!

AlucardZero 03-05-2008 09:22 PM

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.


jschiwal 03-05-2008 09:23 PM

For bash builtins, you can use use "help <command>".

jailbait 03-05-2008 09:33 PM

Quote:

Originally Posted by adnankhawer (Post 3079531)
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

makyo 03-06-2008 08:39 AM

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

AlucardZero 03-06-2008 09:04 AM

Quote:

Originally Posted by jailbait (Post 3079562)
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.

makyo 03-06-2008 10:23 AM

Hi.
Quote:

Originally Posted by AlucardZero (Post 3080036)
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

Emerson 03-06-2008 10:41 AM

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 ...

adnankhawer 03-07-2008 02:24 PM

Thanks very much!!
 
All Dear Fellows,

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


All times are GMT -5. The time now is 07:55 AM.