The bash Shell

Post completing this, you will be able to: 

• Describe the bash shell and its utilities 

• Use command line shortcuts and expansion 

• Describe history tricks 

• Describe and use gnome terminal 

bash Introduction

What is a bash?

Bash is the shell, or command language interpreter, for the GNU operating system. The name is an acronym for “Bourne-Again SHell”, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell /bin/sh, which appeared in the Seventh Edition Bell Labs Research version of Unix. 

Bash is largely compatible with sh and incorporates useful features from the Korn shell ksh and the C shell csh. It is intended to be a conformant implementation of the IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2). It offers functional improvements over sh for both interactive and programming use. 

While the GNU operating system provides other shells, including a version of csh, Bash is the default shell. Like other GNU software, Bash is quite portable. It currently runs on nearly every version of Unix and a few other operating systems – independently-supported ports exist for MS-DOS, OS/2, Windows 95/98, and Windows NT. 

Command Line Shortcuts and Expansion

This is necessary to know about command line shortcuts: 

When typing commands, it is often necessary to issue the same command on more then one file at the same time. The use of Wild cards allows one pattern to expand to multiple filenames with a process called file globbing . Typing the following command $ rm *mp3 is same as typing: $ rm gonk.mp3 zonk.mp3. 

The '*' Wildcard

You will use the asterisk (*) most frequently when you are searching for files. The asterisk allows you search everything that matches the pattern you are looking for. You can specify the pattern, and the operating system performs the search and displays all the files that match the pattern. The ‘*’ wildcard helps to narrow down the SQL Star International 20 The bash Shell SQL Star International 21 search as much as possible. Therefore, when you type the following command, it displays a list of all the files with the extension ‘txt’. 

$ ls *.txt 

Type the following command: 

$ ls sn* 

This command not only displays the file ‘sneakers.txt’, but also displays other files 

with names that begin with ‘sn’. 

The '?' Wildcard

Another way to narrow down the search is to use the question mark symbol (?). Like the asterisk, using ‘?’ helps locate a file that matches a pattern. The ‘?’ wildcard is useful for matching a single character. For instance, give the following command: 

$ ls sneaker?.txt 

It displays all files with the name ‘sneaker’, followed by a single character, and the extension ‘txt’. This would not only display the file ‘sneakers.txt’, but also display the file ‘sneakerz.txt’ (if it exists). 

The '[ ]' Wildcard

You can further limit the search for files by using the ‘[]’ (bracket) wildcard. You can specify a set of values or a range of values in the bracket. The search is based on the values specified in the bracket. For instance, to search a file whose name begins with ‘M’ followed by either ‘A’ or ‘B’ or ‘C’, give the following command: 

 $ ls M[ABC] 

You can also give a range of characters to be matched in the ‘[]’ bracket. For instance, if you are looking for a file whose name starts with ‘M’, followed by any character between ‘A’ to ‘Z’, then the command is: 

 $ ls M[A-Z] 

Type to complete command lines: 

      1. For the command name, it will complete command; 

      2. For an argument, it will complete a file name. 


           $ xte 

          $ xterm 

          $ ls myf 

          $ ls myfile.txt 

‘bash’ stores a history of commands you’ve entered, which can be used to repeat commands. You can use ‘history’ command to see list of “remembered” commands. 

$ history 

In addition to basic command recall with the arrow keys, the bash history mechanism supports a variety of advanced ways of retrieving command from the list. 

!! – To repeat last command 

!c – To repeat last command that started with c 

!n – To repeat command by its number in history output 

History Tricks

Use the up and down arrow keys to scroll through previous commands. Type <CTRL-R> to search for a command on command history. To recall last argument from 

previous command: 

<Esc>. – The escape key followed by a period. 

<Alt> . – Hold down the alt key while pressing the period.


Gnome-terminal is a graphical terminal emulator, with support for maintaining multiple “tabbed” shells simultaneously. 

The path to open gnome-terminal is: 

Applications/System Tool/Terminal 

 <CTRL-SHIFT-t> – Open a new tab 

 <CTRL-PgUp/PgDN> – Next/ Prev tab 

 <CTRL-shift – c/v> – Copy/ Paste 

Leave a Comment

Your email address will not be published. Required fields are marked *