BASH #016 ~ dialog
BASH
Published with SteemPeakSUMMARY
001 BASH .............................................................. v1 19-05
011 bash-guide-for-beginners .......................................... v1 19-06
012 advanced-bash-scripting-guide ..................................... v1 19-06
010 aliases ........................................................... v2 19-06
009 job-control ....................................................... v1 19-06
005 environment ....................................................... v1 19-05
002 script-editor ..................................................... v3 19-05
006 tools ............................................................. v1 19-05
007 tests ............................................................. v1 19-05
004 while-loop ........................................................ v1 19-05
013 bash-to-fish|zsh .................................................. v1 19-06
014 one-liner & cowsay ................................................ v1 19-06
015 zsh ............................................................... v1 19-06
016 dialog ............................................................ v1 19-07 new
003 ~/.bashrc ......................................................... v4 19-06
008 ~/.bash_history ................................................... v1 19-06
010 ~/.bash_aliases ................................................... v2 19-06
#016
016 DIALOG
install ................ # apt install dialog
hello world ............ $ dialog --title 'Message' --msgbox 'Hello world!' 5 20
file viewer ............ $ dialog --textbox ~/.bash_aliases 32 80
check-box .............. $
$ vim menu.sh
#!/bin/bash
# ~/bin/menu.sh
# first steps
# version 1
MENU=`dialog --stdout --no-cancel --clear --menu "Check-Box" 14 20 7 1 one 2 two 3 three 4 four 5 five 6 six q quit`
echo "Item: : $MENU"
:wq
$ chmod 744 ~/bin/menu.sh
Manpages $ man dialog
Tutorial : linuxjournal.com/article/2807
015 ZSH
$ apt install zsh
OH-MY-ZSH
• github.com/robbyrussell/oh-my-zsh
$ sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
$ uninstall_oh_my_zsh
• MAN-Pages : $ man zsh
• FAQ : zsh.sourceforge.net/FAQ/
014 ONE-LINER & COWSAY
INSTALLATION
$ cp ~/.bashrc ~/.bashrc_old
$ echo 'clear' >> ~/.bashrc
$ echo 'echo' >> ~/.bashrc
$ echo 'neofetch' >> ~/.bashrc
$ echo 'cowsay -W 80 -f moose $(cat ~/bin/oneliner.txt | shuf -n1)' >> ~/.bashrc
$ echo 'echo'
$ . ~/.bashrc
ONE-LINER-TEXTFILE
$ vim ~/bin/oneliner.txt
# bash -c "sync; echo 3 > /proc/sys/vm/drop_caches"
# find / -uid 1000 -exec chown -v 1002:1002 {} \;
# find / -user userxyz -type f -exec rm -f {} \;
# find /home -user userxyz -mtime -3
# find /home -user userxyz -size +1G
# mkdir -p /mnt/ram; mount -t tmpfs tmpfs /mnt/ram -o size=8192M
$ alias ea='vim ~/.bash_aliases && source ~/.bash_aliases'
$ cat /etc/passwd | cut -d: -f7 | sort | uniq -c | sort -nr
$ cat /etc/shells
$ curl cheat.sh/:list | less
$ curl wttr.in
$ echo "It is now $(date +%T) on $(date +%A)"
$ find -size +100M | less
$ find -size +1G | less
$ find . -name "*.jpg" -exec convert {} -scale 50% +repage {} \;
$ find /etc -type f -print 2> /dev/null | less
$ find /etc/*tab -type f -print
$ find ~ -maxdepth 1 -type f -exec grep "^alias " '{}' \; -print
$ find ~ -maxdepth 1 -type f -exec grep "^alias " '{}' \; -print
$ find ~ -maxdepth 1 -type f -mtime 3
$ mkdir -p Backups/{Sales,Development,HR}/{Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec}/{Sun,Mon,Tue,Wed,Thu,Fri,Sat}
$ mkdir -p dummy/{1..100}/{1..100}
$ mount | column -t
$ mpg123 -zvC /home/user/music/*
$ ranger ~/.local/share/Trash/
$ scp -r folder/ [email protected]:~
$ scp dummy.txt [email protected]:~
$ sudo -H pip install --upgrade youtube-dl
$ watch -d -n 5 ls -l
$ watch free -h
$ watch mail
:%sort
:wq
013 BASH-TO-FISH|ZSH
$ grep -i user /etc/passwd
$ echo $SHELL
$ cat /etc/shells
# apt install fish zsh
$ cat /etc/shells
• Option 1: # vim /etc/passwd
• Option 2: $ chsh -s /usr/bin/fish
• Option 3: # usermod -s /bin/bash user
$ chsh -s /usr/bin/fish
$ chsh -s /bin/fish
$ cat /etc/passwd | cut -d: -f7 | sort | uniq -c | sort -nr
012 ADVANCED-BASH-SCRIPTING-GUIDE
# apt search abs-guide
# apt show abs-guide
# apt install abs-guide
$ dpkg -L abs-guide
> file:///usr/share/doc/abs-guide/html/index.html
tldp.org/LDP/abs/html/
011 BASH-GUIDE-FOR-BEGINNERS
ldp.org/LDP/Bash-Beginners-Guide/html/index.html
010 ALIASES
$ alias
$ ls -l ~/.bash_aliases
$ cp ~/.bash_aliases ~/.bash_aliases_backup
$ alias > ~/.bash_aliases
$ vim ~/.bashrc
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
:wq
$ vim ~/.bash_aliases
alias a='clear; echo; alias; echo'
alias c='clear; neofetch; cowsay -W 131 -f moose $(cat ~/bin/oneliner.txt | shuf -n1); echo'
alias cc='clear; ncal -wy'
alias ea='vim ~/.bash_aliases && source ~/.bash_aliases'
alias gl='clear; glances'
alias gu='clear; guake &'
alias h='clear; echo; history 30; echo'
alias i='intellij-idea-community &'
alias l='clear; echo; lsd -l; echo'
alias py='clear; python3'
alias r='ranger'
alias s='clear; curl rate.sx/steem@30d'
alias sc='screen -S firstsession'
alias ss='clear; curl rate.sx/steem@1d; gnome-screenshot -ac'
alias ti='clear; tilda&'
alias tm='clear; timew month'
alias tt='clear; task burndown.daily'
alias ttt='clear; task calendar 2019'
alias tw='timew'
alias u='clear; sudo apt update && sudo apt upgrade && sudo apt dist-upgrade; sudo apt autoremove -yy'
alias yt='sudo -H pip install --upgrade youtube-dl'
:wq
009 JOB-CONTROL
$ vim ~/.vimrc <ctrl+z>
$ vim ~/.bashrc <ctrl+z>
$ ranger <ctrl+z>
$ htop <ctrl+z>
$ glances &
$ jobs
$ fg 1
RUN A BACKGROUNd-JOB
$ sleep 10000 &
$ jobs -l
$ kill 12345
SOURCES
$ help jobs
$ help fg
$ help bg
008 HISTORY
$ lsd -l | vim - -g ................................... vim
007 TESTS
STRINGS
$ [ StringA = StringB ]; echo $?
$ [ StringA != StringB ]; echo $?
$ [ -z String ]; echo $?
$ [ -n String ]; echo $?
NUMBERS
$ [ "$NUM" -eq 10 ]; echo $?
$ [ "$NUM" -neq 10 ]; echo $?
$ [ "$NUM" -gt 10 ]; echo $?
$ [ "$NUM" -ge 10 ]; echo $?
$ [ "$NUM" -lt 10 ]; echo $?
$ [ "$NUM" -le 10 ]; echo $?
$ [ -f fileName ]; echo $?
$ [ -d directory ]; echo $?
$ man test
006 TOOLS
$ shellcheck ~/bin/script.sh
005 ENVIRONMENT
$ printenv | awk '/PATH|HOME|USER|SHELL/ {print $0}'
004 WHILE-LOOP
┊ #!/bin/bash
┊ # while-loop
┊ # ~/bin/wl
┊ # wl set `date`
┊
┊ [ -z "$1" ] && exit 1
┊
┊ echo "Command : $0"
┊ echo "Count Args: $#"
┊
┊ COUNTER=1
┊ while [ -n "$1" ]
┊ do
┊ echo "Argument ${COUNTER}: $1"
┊ shift
┊ COUNTER=`expr $COUNTER + 1`
┊ done
┊
┊ exit
003 BASHRC
$ mkdir ~/bin
$ cp ~/.bashrc ~/.bashrc_old
$ vim ~/.bashrc
HISTCONTROL=ignoreboth:erasedups
HISTSIZE=1000
HISTFILESIZE=1000
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
set -o vi
bind -m vi-insert "\C-l":clear-screen
EDITOR=/usr/bin/vim
VISUAL=$EDITOR
export EDITOR VISUAL
export PATH=$HOME/bin:$PATH
:wq
002 SCRIPT-EDITOR
┊ #!/bin/bash
┊ # scripteditor
┊ # ~/bin/ed
┊ # ed scriptname.sh
┊
┊ [ -z "$1" ] && exit 1
┊
┊ DIR=~/bin/
┊
┊ vim "$DIR$1"
┊ chmod 744 "$DIR$1"
┊ clear; echo; lsd -l; echo
┊
┊ exit
001 BASH
SESSION
$ sudo !!
# apt-get update && apt-get upgrade && apt-get dist-upgrade; apt-get autoremove -yy
# init 0
# init 6
# shutdown -c
# shutdown -h 1:00
# shutdown -r now
SUDO
# visudo
> Defaults:user timestamp_timeout=30
Homepage : gnu.org/software/bash/
Documentation : gnu.org/software/bash/manual/html_node/index.html
Congratulations @wglenz! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
To support your work, I also upvoted your post!
This post had received 5.00% upvote from @steemitportugal account!
Vote for @steemitportugal to Witness. Your vote is very important to us!
Visit our WebSite www.steemitportugal.com (tutorials,news...)
Thank you very much.
Click here to vote
Delegation for daily voting: 10SP-25SP-50SP-100SP-250SP-500SP-1000SP