-
Notifications
You must be signed in to change notification settings - Fork 13
/
bash_scripting.html
142 lines (91 loc) · 2.7 KB
/
bash_scripting.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
<title>bash</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="css/slides.css" rel="stylesheet" type="text/css" />
</head>
<body>
<textarea id="source">
class: center, middle
# CSCI-UA 480.10: OSSD
<br>
## bash
.author[
Instructor: Joanna Klukowska <br>
]
.license[
Unless noted otherwise all content is released under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
]
---
# not this kind of bash
<img src="img/dictionary_definition.png" width="800" >
---
# this kind of bash [bash](https://www.gnu.org/software/bash/)
</br></br>
<img src="https://upload.wikimedia.org/wikipedia/commons/8/82/Gnu-bash-logo.svg" width="800" >
</br></br>
</br></br>
.small[bash logo graphic from (https://commons.wikimedia.org/wiki/File:Gnu-bash-logo.svg)[https://commons.wikimedia.org/wiki/File:Gnu-bash-logo.svg] by Justindorfman,
retrieved on March 28, 2018. ]
---
# bash (Unix shell)
- written by Brian Fox
- replacement for the [Bourne shell](https://en.wikipedia.org/wiki/Bourne_shell)
- bash = __b__ourne __a__gain __sh__ell
- first release in 1989
- distributed with most Linux distributions and Allpe's macOs (and recently in
the Microsoft's release of Unix subsystem within Windows 10) as the default shell
- it is a command processor that runs in a text-based terminal window
--
- __interesting fact__
- [Shellshock](https://en.wikipedia.org/wiki/Shellshock_(software_bug))
bug was discovered in Sept. 2014
- the code vulnarability dated back to 1989
---
# a shell script
- A _shell script_ is a text file containing a set of commands that are executed
in order they are written in the script.
- The script works with a particular shell ( _bash_ shell scripts, work with _bash shell_).
- A _shell_ is basically the command line interface.
- The _shell scripts_ are usually small programs that automate various tasks.
---
# running basic commands
- almost anything you type at the terminal is a _bash_ command
(well, some of them may be names of the programs to run, other's may be operating system's
tools, but a large number of things that happen are either _bash_ commands or _bash_ scripts)
- examples
```
echo "Hello World"
echo $(whoami)
```
--
```
which bash
```
--
```
du -sh
```
---
# first script
- create a file consisting of the following lines
```
echo "Hello World"
echo $(whoami)
which $(whoami)
```
- name the file `first`
--
- in a terminal window (running bash), execute:
```
sh first
---
---
</textarea>
<script src="js/remark.js" type="text/javascript">
</script>
<script src="js/remark_conf.js" type="text/javascript">
</script>
</body>
</html>