$ printenv | awk '/PATH|HOME|USER|SHELL/ {print $0}'
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