Differences between revisions 151 and 152
Revision 151 as of 2010-04-06 20:18:21
Size: 6609
Editor: GreyCat
Comment:
Revision 152 as of 2010-05-03 14:22:52
Size: 6645
Editor: Lhunath
Comment:
Deletions are marked like this. Additions are marked like this.
Line 84: Line 84:
 * [[/CommandsAndArguments|Commands and Arguments]]  * [[/01.CommandsAndArguments|Commands and Arguments]]
Line 86: Line 86:
 * [[/SpecialCharacters|Special Characters]]
 * [[/Parameters|Parameters]]
 * [[/02.SpecialCharacters|Special Characters]]
 * [[/03.Parameters|Parameters]]
Line 89: Line 89:
 * [[/Patterns|Patterns]]  * [[/04.Patterns|Patterns]]
Line 91: Line 91:
 * [[/Arrays|Arrays]]  * [[/05.Arrays|Arrays]]
Line 93: Line 93:
 * [[/TestsAndConditionals|Tests and Conditionals]]  * [[/06.TestsAndConditionals|Tests and Conditionals]]
Line 95: Line 95:
 * [[/InputAndOutput|Input and Output]]  * [[/07.InputAndOutput|Input and Output]]
Line 97: Line 97:
 * [[/CompoundCommands|Compound Commands]]  * [[/08.CompoundCommands|Compound Commands]]
Line 99: Line 99:
 * [[/Sourcing|Sourcing]]  * [[/09.Sourcing|Sourcing]]
Line 101: Line 101:
 * [[/JobControl|Job Control]]
 * [[/Practices|Practices]]
 * [[/10.JobControl|Job Control]]
 * [[/11.Practices|Practices]]
Line 106: Line 106:
[[BashGuide/CommandsAndArguments|Commands and Arguments ->]] [[BashGuide/01.CommandsAndArguments|Commands and Arguments ->]]

Commands and Arguments ->


Introduction

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 are invited to report this (consider #bash on irc.freenode.org) 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.

Think of a shell as a way for you to speak to your system. Your system doesn't need it for most of its work, but it is an excellent interface between you and what your system can offer. It allows you to perform basic math, run basic tests and execute applications. More importantly, it allows you to combine these operations and connect applications to each other to perform complex and automated tasks.

BASH is not your operating system. It is not your window manager. It is not your terminal. It does not control your mouse or keyboard. It does not configure your system, activate your screensaver, or open your files when you double-click them. It is generally not involved in launching applications from your window manager. It's important to understand that BASH is only the interface for you to execute statements (using BASH syntax), either at the interactive BASH prompt or via BASH scripts.



  • 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 (generally) 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

The man command opens documentation on a certain application. You use it by running the command man [application] on the BASH prompt, where [application] is the name of the application as you would use to run it on the prompt. It explains that application's purpose and usage in detail.

Note that if you're looking for information on BASH built-ins (commands provided by BASH, not by external applications) you should look in man bash instead. BASH's manual is extensive and detailed. It is an excellent reference; albeit more technical than this document.

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

    $ help
    $ help read



  • 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)