sxiii icon

Руководство по основным и расширенным Bash-командам, скрипты

sxiii | PRO | 01/27/16 10:59:43 AM UTC | 0 ⭐ | 556 👁️ | Never ⏰ | []
Bash |

5.79 KB

|

None

|

0 👍

/

0 👎

#!/bin/bash
###############################################################################
# Понимание исполняемых файлов (программ) / команд "./shell.sh"
# Понимание аргументов "argument=value" 
# Понимание флагов "-f hello-world"
# Понимание системы ввода\вывода команд "> to file < from file | pipes"
# Понимание горячих клавиш Ctrl+C, Ctrl+D, Ctrl+O, Ctrl+X
###############################################################################
 
# Базовые знания по командам (15)
 
width="90"           # Ширина терминала
largefont="mono12"   # Кегель и шрифт для крупных надписей
smallfont="mono9"    # Кегель и шрифт для мелких надписей
 
level1=( "ls" "pwd" "cd" "mkdir/rmdir" "touch/rm" "cat" "cp" "mv" "echo" "clear" "sudo/su" "man" "date" "cal" "hostname" )
text1=( "List" "Print Working Directory" "Change Directory" "Make / Remove Directory" "Touch / Remove" "Concatenate" "Copy" "Move" "Echo" "Clear" "Switch User Do" "Manual" "Date" "Calendar" "Hostname" )
 
for i in "${!text1[@]}"; do
   clear
   echo "$(toilet --width $width -F border -f $largefont --metal ${level1[i]})"
   txt=$(printf '%s \n' "${text1[i]}")
   echo "$(toilet --width $width -f $smallfont --gay $txt)"
   read -rsp $'Next (space)...\n' -n1 key
done
 
# Средний уровень (загрузка, отображение, pipelines, права доступа, устройства) (15)
 
level2=( "wget" "curl" "head/tail" "less/more" "ifconfig/iwconfig" ">, <, |" "chmod/chown" "grep" "wc" "lsusb" "lspci" "sleep" "df" "du" "mount/umount" )
text2=( "Web Get" "Concatinate URL" "(read from) Head/Tail" "(show) Less / More" "InterFace Configuration / Interface Wireless Configuration" "Direct to/from file, pipe" "Change (file/directory) Mode/Change (file/directory) Owner" "Grep..." "Word Count" "List USB" "List PCI" "Sleep" "Disk Files (filesystem usage)" "Disk Usage" "Mount/Unmount" )
 
for i in "${!text2[@]}"; do
   clear
   echo "$(toilet --width $width -F border -f $largefont --metal ${level2[i]})"
   txt=$(printf '%s \n' "${text2[i]}")
   echo "$(toilet --width $width -f $smallfont --gay $txt)"
   read -rsp $'Next (space)...\n' -n1 key
done
 
# Высший уровень (компиляция, управление процессами) (14)
 
level3=( "make" "gcc/g++" "kill/killall" "bg/fg" "pidof" "service" "lshw" "time" "ps/ps aux/pstree" "top/htop" "sort/uniq" "ln" "awk" "dd/dcfldd" )
text3=( "Make" "Gnu C Compiler" "Kill" "BackGround / ForeGround" "Process ID Of" "Service" "List Hardware" "(execution) Time" "Process Snapshot/Process Snapshot Tree" "Top" "(file/dir Sorting / Unique)" "LiNk" "Awk" "Disk Dump" )
 
for i in "${!text3[@]}"; do
   clear
   echo "$(toilet --width $width -F border -f $largefont --metal ${level3[i]})"
   txt=$(printf '%s \n' "${text3[i]}")
   echo "$(toilet --width $width -f $smallfont --gay $txt)"
   read -rsp $'Next (space)...\n' -n1 key
done
 
# Удаленная работа (12)
 
remote=( "ping" "ssh" "scp" "rsync" "ftp" "logout/exit/Ctrl+D/Ctrl+C" "tar" "zip/unzip" "export/env" "screen" "dig" "nmap" )
text4=( "Ping" "Secure Shell" "Secure Copy" "Remote Synchronization" "File Transfer Protocol" "Do I Need To Tell You What Does Logout Means (NINTTYWDLM)?" "Tape ARchive" "Zip" "Export/Environment" "Screen..." "Dig (for some cool info...)" "Network Map" )
 
for i in "${!text4[@]}"; do
   clear
   echo "$(toilet --width $width -F border -f $largefont --metal ${remote[i]})"
   txt=$(printf '%s \n' "${text4[i]}")
   echo "$(toilet --width $width -f $smallfont --gay $txt)"
   read -rsp $'Next (space)...\n' -n1 key
done
 
# Поиск (11)
 
search=( "which" "where" "whoami" "whois" "whatis" "who/w" "history/!" "lsof" "locate" "find" "md5sum/sha256sum" )
text5=( "Which?!" "Where The ...!?" "Who Am I?!?!?!!!" "Who Is This Domain?" "What is this ...?!" "Who" "History..." "List of Open Files" "Locate" "Find" "message digest 5 summ/sha256summ" )
 
for i in "${!text5[@]}"; do
   clear
   echo "$(toilet --width $width -F border -f $largefont --metal ${search[i]})"
   txt=$(printf '%s \n' "${text5[i]}")
   echo "$(toilet --width $width -f $smallfont --gay $txt)"
   read -rsp $'Next (space)...\n' -n1 key
done
 
# Distro-related (5)
 
dl=( "apt-get" "yum" "packer" "pacman" "yaourt" )
text6=("Application Get" "Yum" "Packer" "Package Manager" "Yaourt" )
 
for i in "${!text6[@]}"; do
   clear
   echo "$(toilet --width $width -F border -f $largefont --metal ${dl[i]})"
   txt=$(printf '%s \n' "${text6[i]}")
   echo "$(toilet --width $width -f $smallfont --gay $txt)"
   read -rsp $'Next (space)...\n' -n1 key
done
 
# Полезные сайты (4)
sites=( "commandlinefu.com" "pastebin.com" "distrowatch.com" "alternativeto.net" "github.com" )
text7=( "Command Line Examples" "Paste Bin" "Distribution Watch" "Alternative To" "Git Hub..." )
 
for i in "${!text7[@]}"; do
   clear
   echo "$(toilet --width $width -F border -f $largefont --metal ${sites[i]})"
   txt=$(printf '%s \n' "${text7[i]}")
   echo "$(toilet --width $width -f $smallfont --gay $txt)"
   read -rsp $'Next (space)...\n' -n1 key
done
 
# Bash scripting (5)
scripts=( "if/then/fi" "exit" "while" "arrays" "(command results in arguments)" ) 
text8=( "Conditions" "EXIT!" "While something goes on.." "Arrays are cool!" "Inline results" )
 
for i in "${!text8[@]}"; do
   clear
   echo "$(toilet --width $width -F border -f $largefont --metal ${scripts[i]})"
   txt=$(printf '%s \n' "${text8[i]}")
   echo "$(toilet --width $width -f $smallfont --gay $txt)"
   read -rsp $'Next (space)...\n' -n1 key
done
 
toilet --width 180 -F border -f mono12 --metal 'Congrats - this is the END!'

Comments