Commit aa37ace6 authored by Vincent Tam's avatar Vincent Tam

Post: edit more bash cmd and add missing newlines

parent a319dc50
Pipeline #29517784 passed with stages
in 38 seconds
......@@ -464,7 +464,14 @@ explanations: (in alphabetical order)
### man
Display **man**ual page in a separate se.
Display **man**ual page in a separate session.
### mkdir
**M**a**k**e **dir**ectory.
- `-p`: make parent directory (thanks to
[Fatal Error <i class="fab fa-stack-overflow" aria-hidden></i>][so-mkdir])
### more
......@@ -492,6 +499,8 @@ class="fa fa-terminal fa-stack-1x"></i></span> TTY session into a text file
**S**tream **ed**itor
$ sed [FLAG(S)] '[range][cmd]'
<i class="fa fa-info-circle" aria-hidden></i> <i class="far fa-flag"
aria-hidden></i> <i class="fas fa-sort-alpha-down" aria-hidden></i> Flags
explanations: (in alphabetical order)
......@@ -500,6 +509,31 @@ explanations: (in alphabetical order)
- `-i`: in place editing
- `-n`: no normal output
`[range]` can refer to a line number (`$` meaning the last line), or a scope
`/[PAT]/`. The later can be used to remove empty lines.
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: content/page/bash-commands/index.md
modified: content/page/sublime/index.md
no changes added to commit (use "git add" and/or "git commit -a")
$ git status | sed '/^$/d'
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: content/page/bash-commands/index.md
modified: content/page/sublime/index.md
no changes added to commit (use "git add" and/or "git commit -a")
### sleep
Start an idle process for `n` seconds, which `n` is the first argument.
......@@ -531,8 +565,25 @@ explanations: (in alphabetical order)
### sort
**Sort** input.
### ssh
**S**ecure **sh**ell: access _remote_ desktop on the network through an
_encrypted_ "tunnel".
- simplest syntax: `ssh [USER]@[DOMAIN]`
$ ssh [email protected]
The shell then prompts you to input the password for `[USER]` up. Upon
success, you'll logged in as `[USER]`.
- one-spot connection: `ssh [USER]@[DOMAIN] [CMD]`
$ ssh [email protected] ls ~/quickstart
archetypes config.toml content layouts public static themes
### stty
### tail
......@@ -650,8 +701,65 @@ P.S. It was my favorite editor.
### xargs
Rearrange and/or e**x**ecute **arg**uments.
Output of `ls` _without_ `-l` flag is ascending _column-wise_.
$ ls -A .git
branches description hooks logs ORIG_HEAD
COMMIT_EDITMSG FETCH_HEAD index modules packed-refs
config HEAD info objects refs
`xargs -n [num]` treats input as arguments delimited by space, tab and/or
newline. It outputs `[num]` arguments delimited by space on each line.
$ ls -A .git | xargs -n 3
branches COMMIT_EDITMSG config
description FETCH_HEAD HEAD
hooks index info
logs modules objects
ORIG_HEAD packed-refs refs
Observe the difference of the output below with the first block in this section.
$ ls -A .git | xargs -n 3 | xargs -n 5
branches COMMIT_EDITMSG config description FETCH_HEAD
HEAD hooks index info logs
modules objects ORIG_HEAD packed-refs refs
### xwd
Take screeenshot of graphical desktop from TTY.
I've refined [Neroshan's command][askubu-xwd] on Ask Ubuntu into a shell script.
```bash
#!/bin/sh
# screenshot.sh
# USAGE: ./screenshot.sh [file-name]
chvt 7 # On Xubuntu 18.04
#chvt 1 # On Ubuntu 18.04
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 xwd -root -out ~/screenshot.xwd
convert ~/screenshot.xwd $1
rm ~/screenshot.xwd
chvt `tty | sed 's:/dev/tty::'`
```
This script requires one single argument: output file name (_with extension
name_), which is passed to `$1`. The idea is simple.
1. Switc to GUI from CLI (TTY1--TTY6 on Xubuntu&nbsp;18.04; TTY2--TTY7 on
Ubuntu&nbsp;18.04)
2. Add necessary shell variables. (Adapt it to [GDM] or other display manager)
3. Create a _temporary_ XWD file.
4. [Convert](#convert) this file to a file with your specified file name.
5. Remove the _temporary_ XWD file.
6. Switch back to CLI.
[Vim]: http://www.vim.org
[GIMP]: https://www.gimp.org
[gnu_coreutils]: http://www.gnu.org/s/coreutils/
[so-mkdir]: http://stackoverflow.com/questions/9242163/ddg#9242171
[askubu-xwd]: https://askubuntu.com/a/43475/259048
[GDM]: https://wiki.gnome.org/Projects/GDM
......@@ -102,4 +102,4 @@ highlighting, say
[icon_fonts]: https://packagecontrol.io/packages/Icon%20Fonts
[mdx]: https://packagecontrol.io/packages/Markdown%20Extended
[md]: https://daringfireball.net/projects/markdown/
[soruler]: http://stackoverflow.com/questions/9910143/ddg#11319526
\ No newline at end of file
[soruler]: http://stackoverflow.com/questions/9910143/ddg#11319526
......@@ -44,4 +44,4 @@ thershold to 80%.
[thinkpad]: https://www.lenovo.com/us/en/laptops/thinkpad/thinkpad-x/ThinkPad-X1-Carbon-5th-Gen/p/22TP2TXX15G
[Fujitsu]: http://www.fujitsu.com/
[1]: https://lifehacker.com/5875162/how-often-should-i-charge-my-gadgets-battery-to-prolong-its-lifespan
[2]: https://www.omgubuntu.co.uk/2013/12/check-battery-life-health-ubuntu-linux
\ No newline at end of file
[2]: https://www.omgubuntu.co.uk/2013/12/check-battery-life-health-ubuntu-linux
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