BASH v19-02-27 Update
A short summary of my daily used BASH commands.
homepage tutorial
~/.bashrc
HISTCONTROL=ignoreboth:erasedups
HISTSIZE=1000
HISTFILESIZE=1000
alias c='clear; echo'
alias cc='clear; ncal -3wy'
alias g='clear; glances'
alias l='clear; ls -l'
alias u='clear; sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade; sudo apt-get autoremove -y'
alias h='clear; history 30'
alias r='clear; rsync -avzP --delete --stats --exclude-from "/home/userxyz/.exclude.txt" /home/userxyz/ /media/userxyz/'
alias s1='clear; curl rate.sx/steem@1d; gnome-screenshot -ac'
alias s7='clear; curl rate.sx/steem@7d; gnome-screenshot -ac'
alias s14='clear; curl rate.sx/steem@14d; gnome-screenshot -ac'
alias s21='clear; curl rate.sx/steem@21d; gnome-screenshot -ac'
alias s30='clear; curl rate.sx/steem@30d; gnome-screenshot -ac'
alias s90='clear; curl rate.sx/steem@90d; gnome-screenshot -ac'
alias t='clear; task; timew week; timew summary';
alias tt='clear; task burndown.daily'
alias ttt='clear; task calendar 2019'
alias tw='timew'
alias tm='clear; timew month'
alias py='clear; python3'
EDITOR=vim
VISUAL=$EDITOR
export $EDITOR
export PATH=/home/user1/Apps:/home/user1/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
wg() {
check host
}
export -f wg
set -o vi
bind -m vi-insert "\C-l":clear-screen
SOURCES
• Adv-Bash-Scrip-Guide # apt-get install abs-guide; dpkg -L abs-guide; w3m file:///usr/share/doc/abs-guide/html/index.html
• Tecmint : tecmint.com/linux-commands-cheat-sheet
• TLPD : tldp.org/LDP/Bash-Beginners-Guide/html/index.html
• ComandLineFu : commandlinefu.com
• Die.net : die.net
• Pure Bash Bible : github.com/dylanaraps/pure-bash-bible
• Commandlinefu.com : commandlinefu.com
• Command-Line-Tools : tldp.org/LDP/GNU-Linux-Tools-Summary/html/index.html
• CheatSheet $ curl cheat.sh
$ printenv | awk '/PATH|HOME|USER|SHELL/ {print $0}'
$ cat not_exist.txt 2> /dev/null
$ export PS1='$ '
$ printf "The user %s is %d years old.\n" Max 28
$ set | less
$ shellcheck script.sh
TESTs
$ man test
$ [ StringA = StringB ]; echo $?
$ [ StringA != StringB ]; echo $?
$ [ -z String ]; echo $?
$ [ -n String ]; echo $?
$ [ -f fileName ]; echo $?
$ [ -d directory ]; echo $?
$ [ "$NUM" -eq 10 ]; echo $?
$ [ "$NUM" -neq 10 ]; echo $?
$ [ "$NUM" -gt 10 ]; echo $?
$ [ "$NUM" -ge 10 ]; echo $?
$ [ "$NUM" -lt 10 ]; echo $?
$ [ "$NUM" -le 10 ]; echo $?
BASICS 01
$ mkdir scripts
$ export PATH=$HOME/scripts:$PATH
$ cp ~/.bashrc ~/.bashrc_old
$ echo "export PATH=$HOME/scripts:$PATH" >> ~/.bashrc
$ . ~/.bashrc
BASICS 02
1 #!/bin/bash
2 # wg_info
3 # Basics 02
4 #
5
6 set | less
7 glances
8 clear; ls $HOME/scripts
9 exit
BASICS 03
1 #!/bin/bash
2 # wg_edit scriptname
3 # Basics 03
4 #
5
6 [ -z "$1" ] && exit 1
7
8 vim "$HOME/scripts/$1"
9 chmod 744 "$HOME/scripts/$1"
10 exit
BASICS 04
1 #!/bin/bash
2 # wg_args
3 # Basics 04
4 # wg_args.sh set `date`
5
6 [ -z "$1" ] && exit 1
7 echo "Command : $0"
8 echo "Count Args: $#"
9 COUNTER=1
10 while [ -n "$1" ]
11 do
12 echo "Argument ${COUNTER}: $1"
13 shift
14 COUNTER=`expr $COUNTER + 1`
15 done
16 exit
BASICS 05
1 #!/bin/bash
2 # check [cpu] [network] [disk] [partition]
3 # Wrapper for inxi
4 #
5
6 clear
7
8 while [ -n "$1" ]
9 do
10 case "$1" in
11 "cpu" )
12 inxi -f
13 echo
14 ;;
15 "network" )
16 inxi -i
17 echo
18 ;;
19 "disk" )
20 inxi -D
21 echo
22 ;;
23 "partition" )
24 inxi -p
25 echo
26 ;;
27 esac
28 shift
29 done
30
31 exit