Ben Chuanlong Du's Blog

It is never too late to learn.

Bash Equivalent of the ifmain Pattern in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

#!/usr/bin/env bash

function install_icon.usage() {
    cat << EOF
NAME
    /scripts/sys/install_icon.sh - Download and install icon to /usr/local/bin/.
SYNTAX 
    /scripts/sys/install_icon.sh [-h]
EOF
}

function install_icon …

Get OS and Architecture Information in Shell

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Command Description
uname -a The full info of the machine.
uname The type of OS, e.g., Linux, Darwin, etc.
uname -m The architecture of the machine, e.g., x86_64, etc …

Tips on Shell Commands

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

explainshell.com

  1. command-not-found - Suggest installation of packages in interactive bash sessions

  2. nohup, disown

  3. nautilus-open-terminal

Configuration

https://github.com/thoughtbot/til/blob/master/bash/bash_profile_vs_bashrc.md#:~:text=bashrc%20is%20sourced%20on%20every …

Extended Globbing in Bash

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Enable Extended Globbing

shopt -s extglob

Or you can run bash with the option -O extglob.

/bin/bash -O extglob -c "your command to run"

Set Shell to be Bash with …