Module 51 fg (csh, ksh)

Previous Table of Contents Next


Module 51
fg (csh, ksh)

DESCRIPTION

The internal fg command resumes stopped or suspended jobs by placing them in the foreground. The fg command is part of the job control feature of the C shell and the Korn shell. If a job is in a suspended state you can no longer interface with it. When a job is brought back into the foreground it becomes interactive again.

COMMAND FORMAT

Following is the general format of the fg command.

 fg [ %job ... ] 

Arguments

The following arguments may be passed to the fg command.

%job A job number associated with a process. If the interactive option is turned on, job may be one of the following:
% num A job number associated with a process
% string The job whose name begins with string
%? string The job whose name contains string
%+
%%
Current process, the last process you stopped or suspended
%- Previous process, the job before the current job

RELATED COMMANDS

Refer to the bg , jobs , and kill commands described in modules 9, 68, and 70.

APPLICATIONS

The fg command is used to force suspended or stopped jobs into the foreground. This brings the job back into interactive mode, allowing you to interface with it from your keyboard. For instance, if you are in vi and decide to suspend the editor, you type Ctrl-Z. Now vi is suspended in background. You can use the jobs command to display all background and suspended jobs. After you perform various other commands you can return to your suspended vi session by typing fg %1 and pressing Return . Since this is the current job you could just type fg .

TYPICAL OPERATION

In this activity you use the fg command to restart a process you have suspended. Begin at the shell prompt.

1.    Type vi x and press Return .
 cj> vi x 
2.    Press Ctrl-Z to suspend vi .
 ^Z      ~      .      .      ~      "x" [New file]      [1] + Stopped                 vi x      cj> 

The [1] specifies the job number.
3.    Type ps and press Return . This shows the vi process in your process table. You can continue to perform commands until you are ready to reenter vi.
4.    Type fg %1 and press Return to restart your vi session. You will return to your vi session.
5.    Type :q! and press Return to exit vi .
6.     Turn to Module 68 to continue the learning sequence.


Previous Table of Contents Next

Copyright Wordware Publishing, Inc.


Illustrated UNIX System V
Illustrated Unix System V/Bsd
ISBN: 1556221878
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Robert Felps

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net