summaryrefslogtreecommitdiffstats
path: root/software/bash.page
blob: 0a3f73f1965adb2bfd8e684e94fcb1f0d6dd1547 (plain)
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
---
format: rst
toc: no
...

==================
BASH
==================

Job Control
    The syntax for "job number" or "JOBSPEC" (when using ``kill`` or similar) is ``%4`` or ``%5``.

Startup
-------
``bash`` by default takes a very long time to initialize because the
auto-completion scripts are loaded multiple times; disable this in
``~/.bashrc``?

Piping
---------
You can pipe both ``stdout`` and ``stderr`` together either to a file or two another command::

    grep --asdf >& /some/file
    grep --asdf |& less

Network Access
----------------
You can directly access network sockets as if they were files from bash using
the virtual devices ``/dev/tcp/HOSTNAME/PORT`` and ``/dev/udp/HOSTNAME/PORT``.

printf
------
The ``printf`` command is much more powerful than "echo".

Prelude
-------

`set`:

    -e          fail on error
    -u          fail if variable not set in substitution
    -o pipefail fail if part of a '|' command fails