Commit f1bcfa60 authored by Vincent Tam's avatar Vincent Tam

Post: editing bash cmd list

parent 38ddf79d
Pipeline #29033572 failed with stages
in 41 seconds
......@@ -6,13 +6,17 @@ date: 2018-08-28T17:18:27+02:00
### Background settings
Take the local Git repo of this blog as an example.
Take the local <i class="fa fa-git" aria-hidden></i> repo of this blog as an
example.
Show current path.
# Show current path
$ pwd
/home/vin100/quickstart
# distinguish files from folders
Distinguish files <i class="fa fa-file-o" aria-hidden></i> from folders <i
class="fa fa-folder-o" aria-hidden></i>.
$ ls -l
total 28
drwxrwxr-x 2 vin100 vin100 4096 Jun 28 21:00 archetypes
......@@ -23,57 +27,151 @@ Take the local Git repo of this blog as an example.
drwxrwxr-x 4 vin100 vin100 4096 Aug 25 13:36 static
drwxrwxr-x 3 vin100 vin100 4096 Aug 27 18:06 themes
### apg
### awk
### blkid
Display hard disk UUID.
### cat
**Cat**enate files and display them (in STDOUT).
### convert
### date
### du
Disk usage. Only folders <i class="fa fa-folder-o" aria-hidden></i> are shown
by default.
Display **d**isk **u**sage in KB. Only folders <i class="fa fa-folder-o"
aria-hidden></i> are shown by default.
General usage: `du [FLAG(S)] [DIR(S)] ...`
If the argument `[DIR(S)]` is omitted, the size of _every_ (sub)folder <i
class="fa fa-folder-o" aria-hidden></i> (including _hidden_ ones) will be
displayed.
# display the size of every (sub)folder (including hidden ones) in KB.
$ du
...
# display the size of a subtree 'layouts' in KB.
Display the size of _each_ subfolder <i class="fa fa-folder-o" aria-hidden></i>
in the folder `layouts`.
$ du layouts
12 layouts/partials
20 layouts/
<i class="fa fa-info-circle" aria-hidden></i> <i class="fa fa-tag"
aria-hidden></i> <i class="fa fa-sort-alpha-asc" aria-hidden></i> Tags
<i class="fa fa-info-circle" aria-hidden></i> <i class="fa fa-flag-o"
aria-hidden></i> <i class="fa fa-sort-alpha-asc" aria-hidden></i> Flags
explanations: (in alphabetical order)
- `-a`: also include all files
- `-c`: include grand total at the bottom
- `-d`: max depth
$ du -c layouts static
12 layouts/partials
20 layouts
8 static/css
196 static/img
212 static
232 total
- `-d [n]`: max depth
Process contents <i class="fa fa-folder-o" aria-hidden></i> of `[DIR]` up to
at most `n` level(s) deep.
I found the concept of "level" hard to understand when I ran this in `.`
because the output was cluttered with fo||lders <i class="fa fa-folder-o"
aria-hidden></i> holding <i class="fa fa-git" aria-hidden></i> objects.
Let me illustrate this idea with the following example.
$ du -d 2 content
8 content/post/2018-08-29-csb-theorem
16 content/post/2018-07-17-rodeo
248 content/post/2018-07-07-upgraded-to-linux-mint-19
500 content/post/2018-08-18-ubuntu-18-04-installation-on-fujitsu-ah557
76 content/post/2018-07-26-web-image-optimisation-with-gimp
920 content/post/2018-07-04-fujitsu-lh532-fan-cleaning
388 content/post/2018-08-23-brighten-image-with-gimp
1412 content/post/2018-07-23-fujitsu-lh532-keyboard-cleaning
3624 content/post
12 content/page/bash-commands
20 content/page
3652 content
#### |-------|----|-----------------------------------------------------|
Lv 0 Lv 1 Lv 2
- `-h`: human readable
$ du -h layouts
12K layouts/partials
20K layouts/
- `--exclude=[FILE]`
- `-s`: summary, display only the directory
- `-s`: summary, display only the directory in the argument. (equivalent to `-d
0`)
- `--time`: also display time in the middle of each row
### echo
Display all arguments.
Display all arguments (in STDOUT).
$ echo foo bar
foo bar
- `-e`: enable regular expressions
+ `\a`: shell beep (_disabled_ in Ubuntu by default)
$ echo -e "\a"
$
+ `\n`: newline
+ `\t`: tab
- `-n`: _don't_ output newline character `\n` at the end
$ echo -en "\a"
$
### find
### git
### git-annex
### grep
**G**et **r**egular **e**xpression and **p**rint.
General usage:
- read from file(s): `grep [FLAGS] [PATTERN] [FILE]`
- pipe from STDIN: `[cmd] | grep [FLAGS] [PATTERN]`
- read from file(s): `grep [FLAG(S)] [PATTERN] [FILE]`
- pipe from STDIN: `[cmd] | grep [FLAG(S)] [PATTERN]`
- read from STDIN:
1. <span class="fa-stack"> <i class="fa fa-square-o fa-stack-2x"></i> <i
class="fa fa-terminal fa-stack-1x"></i> </span> Type `grep [PATTERN]`.
$ grep foo
2. <i class="fa fa-keyboard-o" aria-hidden></i> Input the content to be
searched. After you've finished, terminate the line with a newline
character.
$ grep foo
foobar
3. Your search content is _duplicated_, with the matching part
**highlighted**.
<i class="fa fa-info-circle" aria-hidden></i> <i class="fa fa-tag"
aria-hidden></i> <i class="fa fa-sort-alpha-asc" aria-hidden></i> Tags
<i class="fa fa-info-circle" aria-hidden></i> <i class="fa fa-flag-o"
aria-hidden></i> <i class="fa fa-sort-alpha-asc" aria-hidden></i> Flags
explanations: (in alphabetical order)
- `-A [n]`: print `n` lines _after_ the matching line
......@@ -93,6 +191,24 @@ explanations: (in alphabetical order)
- `-E`: use regular expression in the search string
- `-i`: ignore case
- `-I`: ignore binary files
$ cd content/post/2018-07-23-fujitsu-lh532-keyboard-cleaning
$ grep if *
Binary file 20180708_234331_HDR.jpg matches
Binary file 20180709_001359_HDR.jpg matches
...
index.md:Finally the N key was fixed: *no* noticeable difference from other norm
al size
Use this flag to ignore the JPG files <i class="fa fa-photo"
aria-hidden></i> (and match the text files only).
$ grep -I if *
...
index.md:Finally the N key was fixed: *no* noticeable difference from other norm
al size
- `-l`: show matched _file path_
- `-L`: show unmatched file path
- `-n`: also show matching line number
......@@ -119,6 +235,24 @@ explanations: (in alphabetical order)
- `-w`: match whole _word_, similar to `\<` and `\>` in [Vim].
- `-q`: quiet
### ifconfig
Display and/or modify connection info.
### less
Show the file in a seperate popup session with some [Vim] like key bindings.
General usage: `less [FILE]`
$ less config.toml
| Key <i class="fa fa-keyboard-o" aria-hidden></i> | Function |
| --- | --- |
| `h` | Show help page |
| `j` | Scroll one line down |
| `k` | Scroll one line up |
### ls
List files <i class="fa fa-file-o" aria-hidden></i> in a directory <i class="fa
......@@ -126,14 +260,14 @@ fa-folder-o" aria-hidden></i>.
Default aliases:
| <span class="fa-stack"> <i class="fa fa-square-o fa-stack-2x"></i> <i class="fa fa-terminal fa-stack-1x"></i> </span> | Tags added <i class="fa fa-tag" aria-hidden></i> |
| <span class="fa-stack"> <i class="fa fa-square-o fa-stack-2x"></i> <i class="fa fa-terminal fa-stack-1x"></i> </span> | Flags added <i class="fa fa-flag-o" aria-hidden></i> |
|---|---|
|`l` | `-CF` |
| `la` | `-A` |
| `ll` | `-alF` |
<i class="fa fa-info-circle" aria-hidden></i> <i class="fa fa-tag"
aria-hidden></i> <i class="fa fa-sort-alpha-asc" aria-hidden></i> Tags
<i class="fa fa-info-circle" aria-hidden></i> <i class="fa fa-flag-o"
aria-hidden></i> <i class="fa fa-sort-alpha-asc" aria-hidden></i> Flags
explanations: (in alphabetical order)
- `-a`: all
......@@ -178,4 +312,32 @@ explanations: (in alphabetical order)
I use `-d` with `*` to keep `ls` from expanding the subfolders. <i
class="fa fa-folder-o" aria-hidden></i>.
### more
### openssh
### rsync
### screendump
### sed
### shrinkpdf
### sort
### ssh
### stty
### tee
### uniq
### vim
### wc
### xwd
[Vim]: http://www.vim.org
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment