You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/posts/linux-command-line.md
+15-5Lines changed: 15 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,7 @@ description: |
8
8
And i will cover the basics of shell scripting.
9
9
10
10
summary: "In this guide i will be covering the linux command line basics"
11
-
ShowToc: true
12
-
TocOpen: true
11
+
ShowToc: false
13
12
ShowBreadCrumbs: true
14
13
---
15
14
@@ -165,9 +164,12 @@ But you can be sure that all major Linux distros come with the binaries of those
165
164
166
165
## Shebangs
167
166
168
-
description of shebangs here.
167
+
You will often encounter shell scripts starting with ``#!/bin/bash``, the ``#!`` is called a shebang. It is used to specify which interpreter will be used to run the script.
168
+
So if your script uses bash specific scripting syntax, then you put a bash shebang on the first line of your script.
169
+
If you want your script to be posix compatible so it can run on other unix like systems that don't have bash, then you use the sh shebang.
170
+
The sh shell is compatible with alot more unix like operating systems than just linux, making your scripts more portable at the cost of bash specific scripting features.
169
171
170
-
### Bash Shebangs
172
+
### Bash Compatible:
171
173
172
174
<table>
173
175
<tr>
@@ -217,7 +219,7 @@ description of shebangs here.
217
219
</tr>
218
220
</table>
219
221
220
-
### Posix Shebangs
222
+
### Posix Compatible:
221
223
222
224
<table>
223
225
<tr>
@@ -267,6 +269,14 @@ description of shebangs here.
267
269
</tr>
268
270
</table>
269
271
272
+
### Conclusion:
273
+
274
+
Just use ``#!/bin/bash`` for linux bash scripts.
275
+
276
+
Just use ``#!/usr/bin/env bash`` for cross platform bash scripts.
277
+
278
+
Just use ``#!/bin/bash`` or ``#!/usr/bin/env sh`` for cross platform posix scripts.
0 commit comments