... we remember

The Central Ohio Linux User Group

Ohio's Oldest Linux User Group

  This site is powered by:  
[A friend in France - http://www.aldil.org/]
Home Page Mailing List Meetings Links Topics Source Code Presentations Knowledge User Groups Adminstrivia Click for Columbus, Ohio Forecast
NWS Port Columbus

 The Bash Shell by Paul Hostetler  [ Up ] 
This presentation was given by Paul Hostetler at a meeting held at the Metropolitan Human Services Commission, in Columbus, Franklin County, Ohio.

From a presentation given to the Central Ohio Linux User Group in January 1999 by Paul Hostetler.


Typical Command Syntax: command modifiers arguments
Example with modifiers:
  ls --color=auto ?[a-c]*  
Lists (in color) all files where the second character in the filename is a, b, or c.
Example without modifiers:
  echo $TERM  
Echoes the value of the variable TERM to standard output.

Reserved Words

if

then

else

elif

fi

case

esac

     

for

while

until

do

done

function

in

select

   

!

{

}

time

 

Job Control

command

Starts a command in the foreground.

command_A &

Starts command_A in the background. Inappropriate for interactive jobs (e.g. less.)

^Z

Suspends a running command.

jobs

Lists all jobs.

fg %n

Brings job n back into the foreground. Can be used without %n

^c

Interrupts a running job.

^\

Kills a running job. Use when ^c fails. Leaves core file.

command_A ; command_B

Starts command_A then starts command_B when command_A is complete. If commands become long, using the \ character splits the command line.

(A ; B) & (C ; D) &

Starts A followed by B concurrently with C followed by D.  All jobs run in the background.

nohup command_A &

Starts command_A in the background ignores hangups.

Redirection

command_A | command_B

Sends std. output of command_A to command_B as std. input.Example: procinfo | elm username@someaddress.orgMails output of procinfo to username@someaddress.org

command > filename

Directs std. output of command_A to filename. Overwrites (clobbers) existing file.Example:rpm -qa | sort > installed_packagesSends output of rpm -qa (lists all installed packages) to the sort command and then sends the sorted output to the file installed_packages. (Note > is equivalent to 1> where 1 is the file descriptor for standard output. 2 is the file descriptor for standard error.)Example:startx > xerrors 2>&1 &Starts the X server and sends the standard output and standard error to the file xerrors.

command >> filename

Same as > except that it appends the data to filename if it already exists.

command < filename

Take input for command from filename.

Example:

elm s "RPM List"
username@someaddress.org < installed_packages

Mails installed_packages file to
username@someaddress.org  with the title "RPM List."

command | tee filename

Sends output of command to filename and to standard output.

Filename Expansion (Globbing)

*

Matches any filename not starting with . (excludes "hidden" files.)

Example:

*.c
Matches all files ending in .c

*c
Matches all files ending with c

c*
Matches all files starting with c

.c*
Matches all files starting with .c ("hidden" files)

?

Matches any single character.

Example:

?ood
Matches all files four characters long ending in ood
Wood wood 1ood @ood

f?
Matches all two charachters long starting with f
fe fi fo fm

[]

Matches a range of characters.

Example:

[1-5]
Matches 1-5

[c,o]
Matches c or o

[c-o]
Matches c through o

Command History

history

Lists previous commands.

!n

Executes command n from the command history.

!!

Executes previous command.

!string

Executes previous command starting with string.

!?string?

Executes previous command containing string.

Aliases

alias somecommand="someothercommand possible_modifiers"

Sets alias

unalias somecommand="someothercommand possible_modifiers"

Clears alias.

Aliases are usually set in .bashrc or /etc/bashrc

Interested in color ls?  Add the line

alias ls="ls color=auto"

to your /etc/bashrc file and then

source /etc/bashrc

or reboot.

 

Emacs and the bash Shell

^a

Go to beginning of line.

^e

Go to end of line.

^w

Delete previous word.

^p

(History) Previous command.

^n

(History) Next command.

^k

Kill rest of line.

^b

Back one character.

^f

Forward one character.

^d

Deletes character. Exits bash at blank command line.




Note: This page was initially generated by a legacy OS web page generation tool, and as such was littered with bizarre approaches to 'pretty-printing' HTML. It was manually re-hacked into a table structure, and cleaned up for a display presentation to work with lynx. Any errors in HTML presentation are the result of its initial generation, and not of the author.


  Copyright © 2000 The Central Ohio Linux User Group. Hunh?
All rights reserved.
Search