Differences between revisions 145 and 146
Revision 145 as of 2009-02-18 16:40:12
Size: 600
Editor: GreyCat
Comment: category
Revision 146 as of 2009-12-28 18:09:14
Size: 5014
Editor: GreyCat
Comment: manual TOC for the whole guide; merge most of the old /Introduction
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## The Bash Guide
## ~ lhunath
Line 4: Line 2:
#pragma section-numbers on [[BashGuide/CommandsAndArguments|Commands and Arguments ->]]
----
= Introduction =
'''This guide is currently still a work in progress. It grows a little every day. You are invited to make additions or modifications so long as you can keep them accurate (and linguistically correct).'''
Line 6: Line 7:
= Contents: Bash Guide = All the information here is presented without any warranty or guarantee of accuracy. Use it at your own risk. When in doubt, please consult the man pages or the GNU info pages as the authoritative references.
Line 8: Line 9:
<<TableOfContents>>
## Until TableOfContents.py gets fixed, every page will have to be manually included.
## Currently, using the regex makes the ToC have links pointing to the wrong anchors.
## <<Include(^BashGuide/.*, , editlink)>>
[[BASH]] is a BourneShell compatible shell, which adds many new features to its ancestor. Most of them are available in the 'KornShell', too.
Line 13: Line 11:
<<Include(BashGuide/Introduction, , editlink)>>
<<Include(BashGuide/TheBasics, , editlink)>>
<<Include(BashGuide/Practices, , editlink)>>
--------
<<Anchor(About)>>
= About This Guide =

This guide aims to become a point of reference for people interested in learning to work with [[BASH]]. It aspires to teach its readers good practice techniques in developing scripts for the [[BASH]] interpreter and educate them about the internal operation of [[BASH]].

This guide is targeted at beginning users. It assumes no basic knowledge, but rather expects you to have enough common sense to put two and two together. If something is unclear to you, you should report this so that it may be clarified in this document for future readers.

You are invited to contribute to the development of this document by extending it or correcting invalid or incomplete information.

The maintainer(s) of this document:

 * -- [[Lhunath]] (primary author)
 * -- GreyCat

--------
<<Anchor(Definition)>>
= A Definition =

[[BASH]] is an acronym for '''''B'''ourne '''A'''gain '''Sh'''ell''. It is based on the ''Bourne'' shell and is mostly compatible with its features.

Shells are applications that provide users with the ability to give commands to their operating system interactively, or to allow them to execute batch processes quickly. In no way are they required for execution of processes; they are merely a layer between system function calls and the user.

--------
 . '''In The Manual: [[http://www.gnu.org/software/bash/manual/bashref.html#SEC1|Introduction]]'''
----
 . ''Shell'': A (possibly interactive) layer between the user and the system. <<BR>> ''[[BASH]]'': The Bourne Again Shell, a ''Bourne'' compatible shell.

--------
<<Anchor(Using_Bash)>>
= Using Bash =

Most users that think of [[BASH]] think of it as a prompt and a command line. That is [[BASH]] in ''interactive mode''. [[BASH]] can also run in ''non-interactive mode'' through scripts. We can use scripts to automate certain logic. Scripts are basically lists of commands that you can type on the command line. When such a script is executed, all these commands are executed sequentially, one after another.

We'll start with the basics in an ''interactive shell''. Once you're familiar with those, you can put them together in scripts.

'''Important! <<BR>> You should make yourself familiar with the `man` and `apropos` commands on the shell. They will be vital to your self-tutoring.'''

{{{
    $ man man
    $ man apropos
}}}

[[BASH]] also offers a `help` command which contains brief summaries of some of its built-in commands (which we'll discuss later on).

{{{
    $ help
}}}

--------
 . '''In the FAQ: <<BR>> [[BashFAQ/061|Is there a list of which features were added to specific releases (versions) of Bash?]]'''
----
 . ''Interactive mode'': A mode of operation where a prompt asks you for one command at a time.
 . ''Script'': A file that contains a sequence of commands to execute one after the other.
--------

= Contents =

The guide has been divided into sections, which are intended to be read roughly in the order presented. If you skip ahead to a specific section, you might find yourself missing some background information from previous sections. (Links to relevant sections are not always provided when a topic is mentioned.)

 * [[/CommandsAndArguments|Commands and Arguments]]
  * Types of commands; argument splitting; writing scripts.
 * [[/SpecialCharacters|Special Characters]]
 * [[/Parameters|Parameters]]
  * Variables; special parameters; parameter types; parameter expansion.
 * [[/Patterns|Patterns]]
  * Globs; filename matching; extended globs; regular expressions.
 * [[/Arrays|Arrays]]
 * [[/TestsAndConditionals|Tests and Conditionals]]
  * Exit status; {{{&&}}} and {{{||}}}; if, test and {{{[[}}}; while, until and for; case and select.
 * [[/InputAndOutput|Input and Output]]
  * Redirection; here documents; here strings; pipes; process substitution.
 * [[/CompoundCommands|Compound Commands]]
  * Aliases; functions.
 * [[/Sourcing|Sourcing]]
  * Reading commands from other files.
 * [[/JobControl|Job Control]]
 * [[/Practices|Practices]]
  * Choosing your shell; quoting; readability; debugging.
Line 18: Line 92:
[[BashGuide/CommandsAndArguments|Commands and Arguments ->]]
----

Commands and Arguments ->


Introduction

This guide is currently still a work in progress. It grows a little every day. You are invited to make additions or modifications so long as you can keep them accurate (and linguistically correct).

All the information here is presented without any warranty or guarantee of accuracy. Use it at your own risk. When in doubt, please consult the man pages or the GNU info pages as the authoritative references.

BASH is a BourneShell compatible shell, which adds many new features to its ancestor. Most of them are available in the 'KornShell', too.


About This Guide

This guide aims to become a point of reference for people interested in learning to work with BASH. It aspires to teach its readers good practice techniques in developing scripts for the BASH interpreter and educate them about the internal operation of BASH.

This guide is targeted at beginning users. It assumes no basic knowledge, but rather expects you to have enough common sense to put two and two together. If something is unclear to you, you should report this so that it may be clarified in this document for future readers.

You are invited to contribute to the development of this document by extending it or correcting invalid or incomplete information.

The maintainer(s) of this document:


A Definition

BASH is an acronym for Bourne Again Shell. It is based on the Bourne shell and is mostly compatible with its features.

Shells are applications that provide users with the ability to give commands to their operating system interactively, or to allow them to execute batch processes quickly. In no way are they required for execution of processes; they are merely a layer between system function calls and the user.



  • Shell: A (possibly interactive) layer between the user and the system.
    BASH: The Bourne Again Shell, a Bourne compatible shell.


Using Bash

Most users that think of BASH think of it as a prompt and a command line. That is BASH in interactive mode. BASH can also run in non-interactive mode through scripts. We can use scripts to automate certain logic. Scripts are basically lists of commands that you can type on the command line. When such a script is executed, all these commands are executed sequentially, one after another.

We'll start with the basics in an interactive shell. Once you're familiar with those, you can put them together in scripts.

Important!
You should make yourself familiar with the man and apropos commands on the shell. They will be vital to your self-tutoring.

    $ man man
    $ man apropos

BASH also offers a help command which contains brief summaries of some of its built-in commands (which we'll discuss later on).

    $ help



  • Interactive mode: A mode of operation where a prompt asks you for one command at a time.

  • Script: A file that contains a sequence of commands to execute one after the other.


Contents

The guide has been divided into sections, which are intended to be read roughly in the order presented. If you skip ahead to a specific section, you might find yourself missing some background information from previous sections. (Links to relevant sections are not always provided when a topic is mentioned.)


Commands and Arguments ->


CategoryShell

BashGuide (last edited 2015-04-10 20:29:39 by GreyCat)