Chapter1. Bash Basics

What is a Shell

A shell is any user interface to the UNIX operating system, i.e., any program that takes input from the user, translates it into instructions that the operating system can understand, and conveys the operating system’s output back to the user.
image.png-59.6kB

There are various types of user interfaces. bash belongs to the most common category, known as character-based user interfaces.

Remember that the shell itself is not UNIX just the user interface to it. UNIX is one of the first operating systems to make the user interface independent of the operating system.

History of UNIX Shells

The first major shell was the Bourne shell (named after its inventor, Steven Bourne); it was included in the first popular version of UNIX, Version 7, starting in 1979.

The first widely used alternative shell was the C shell, or csh. This was written by Bill Joy at the University of California at Berkeley as part of the Berkeley Software Distribution (BSD) version of UNIX that came out a couple of years after Version 7.

In recent years a number of other shells have become popular. The most notable of these is the Korn shell. This shell is a commercial product that incorporates the best features of the Bourne and C shells, plus many features of its own.

The Bourne Again shell (named in punning tribute to Steve Bourne’s shell) was created for use in the GNU project.[2] The GNU project was started by Richard Stallman of the Free Software Foundation (FSF) for the purpose of creating a UNIX-compatible operating system and replacing all of the commercial UNIX utilities with freely distributable ones.

bash, intended to be the standard shell for the GNU system, was officially “born” on Sunday, January 10, 1988. Brian Fox wrote the original versions of bash and readline and continued to improve the shell up until 1993.

You might be able to find the location by typing whereis bash (especially if you are using the C shell); if that doesn’t work, try whence bash, which bash, or this complex command

Files

Files are the most important types of “things” on any UNIX system. A file can contain any kind of information, and indeed there are different types of files. Three types are by far the most important:

  • Regular files: Also called text files; these contain readable characters.
  • Executable files: Also called programs, The shell itself is a (non-human-readable) executable file called bash.
  • Directories: These are like folders that contain other files

cd -: changes to whatever directory you were in before the current one.
ls -l': tells ls to list the file’s owner, size, time of last modification, and other information.
ls -a: lists all files including the hidden files.

Basic wildcards

WildcardMatches
?Any single character
*Any strings characters
[set]Any character in set
[!set]Any character not in set

pathname expansion: it ispossible to use wildcards in the current directory, they can also be used as part of a pathname.
Brace Expansion: echo b{ed,olt,ar}s echo {d..h} h.

Input and Output

The UNIX I/O scheme is based on two dazzlingly simple ideas.

  • UNIX file I/O takes the form of arbitrarily long sequences of characters (bytes).
  • Everything on the system that produces or accepts data is treated as a file. this includes hardware devices like disk drives and terminals.

Popular UNIX data filtering utilities

UtilityPurpose
catCopy input to output
grepSearch for strings in the input
sortSort lines in the input
cutExtract columns from input
sedPerform editing operations on input
trTranslate characters in the input to other characters

all of them (and most other UNIX utilities) accept input from standard input if you omit the argument.

nice command, where command can be a complex shell command line with pipes, redirectors, etc., then the command will run at a lower priority.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值