部分 II. Shell

目錄

18. Bash Shell
18.1. bash - GNU Bourne-Again SHell
18.1.1. -n 檢查腳本是否有語法錯誤
18.1.2. -x 顯示詳細運行過程
18.2. Introduction
18.2.1. chsh - change login shell
18.2.2. test 命令
18.2.3. I/O 重定向
18.2.3.1. error 重定向
18.2.3.2. 使用塊記錄日誌
18.2.3.3. tee - read from standard input and write to standard output and files
18.2.3.4. 創建檔案
18.2.3.5. 快速清空一個檔案的內容
18.2.4. pipes (FIFOs)
18.2.5. mktemp - create a temporary file or directory 臨時目錄與檔案
18.2.6. History 命令歷史記錄
18.2.6.1. .bash_history
18.2.6.2. .mysql_history
18.2.7. hash - hash database access method
18.2.8. prompt
18.3. variable
18.3.1. 表達式
18.3.2. Internal Environment Variables
18.3.3. set 設置變數
18.3.4. unset 變數銷毀
18.3.5. 設置變數預設值
18.3.6. export 設置全局變數
18.3.7. declare
18.3.8. 系統變數
18.3.9. Strings
18.3.9.1. ##/#
18.3.9.2. %%/%
18.3.9.3. :n1:n2
18.3.9.4. #
18.3.9.5. example
18.3.9.6. 計算字元串長度
18.3.10. Array
18.3.11. eval
18.4. conditions if and case
18.4.1. if
18.4.2. case
18.5. Loops for, while and until
18.5.1. for
18.5.2. while
18.5.3. until
18.6. Functions
18.6.1. Local variables
18.7. User interfaces
18.7.1. input
18.8. Example
18.8.1. 有趣的Shell
18.8.2. backup
18.8.3. CPU 核心數
18.8.4. Password
18.8.5. processes
18.8.5.1. pid
18.8.5.2. kill
18.8.5.3. pgrep
18.8.6. Shell 技巧
18.8.6.1. 行轉列,再批評
18.8.6.2. for vs while
18.8.6.3. 遍歷字元串
18.8.7. to convert utf-8 from gb2312 code
18.8.8. 使用內存的百分比
18.8.9. 合併apache被cronlog分割的log檔案
19. Z Shell
19.1. installing Z shell
19.2. Starting file
19.2.1. ~/.zshrc
19.3. Prompting
19.4. Aliases
19.5. History
19.6. FAQ
19.6.1. Home/End key
20. Shell command
20.1. Help Commands
20.1.1. man - an interface to the on-line reference manuals
20.1.1.1. manpath.config
20.1.1.2. 查看man手冊位置
20.1.1.3. 指定手冊位置
20.2. getconf - Query system configuration variables
20.3. Directory and File System Related
20.3.1. dirname
20.3.2. filename
20.3.2.1. 排除副檔名
20.3.2.2. 取副檔名
20.3.3. test - check file types and compare values
20.3.4. stat
20.3.5. mkdir - make directories
20.3.6. rename
20.3.7. touch
20.3.8. ls - list directory contents
20.3.9. cp - copy files and directories
20.3.9.1. copy directories recursively
20.3.9.2. overwrite an existing file
20.3.9.3. -a, --archive same as -dR --preserve=all
20.3.10. rm - remove files or directories
20.3.10.1. -bash: /bin/rm: Argument list too long
20.3.10.2. zsh: sure you want to delete all the files in /tmp [yn]?
20.3.11. df - report file system disk space usage
20.3.12. du - estimate file space usage
20.3.13. tac - concatenate and print files in reverse
20.3.14. split - split a file into pieces
20.3.14.1. 按行分割檔案
20.3.14.2. 按尺寸分割檔案
20.3.15. find - search for files in a directory hierarchy
20.3.15.1. name
20.3.15.2. regex
20.3.15.3. user
20.3.15.4. perm
20.3.15.5. type
20.3.15.6. -delete
20.3.15.7. exec
20.3.15.8. xargs
20.3.15.9. 排除目錄
20.3.15.10. -mtime / -mmin
20.3.15.11. --newer
20.3.15.12. -print / -printf
20.3.15.13. -size
20.4. package / compress and decompress
20.4.1. tar — The GNU version of the tar archiving utility
20.4.1.1. tar examples
20.4.1.2. gunzip
20.4.1.3. b2zip
20.4.1.4. compress
20.4.1.5. -t, --list
20.4.1.6. tar: Removing leading `/’ from member names
20.4.1.7. -C, --directory=DIR
20.4.1.8. -P, --absolute-names don't strip leading `/'s from file names
20.4.1.9. --exclude
20.4.1.10. -T
20.4.1.11. 日期過濾
20.4.1.12. 保留權限
20.4.1.13. -r, --append
20.4.1.14. 遠程傳輸
20.4.1.15. 分卷壓縮
20.4.2. cpio - copy files to and from archives
20.4.3. gzip
20.4.4. zip, zipcloak, zipnote, zipsplit - package and compress (archive) files
20.4.5. RAR
20.4.6. 7-Zip
20.4.6.1. 壓縮
20.4.6.2. 瀏覽壓縮包
20.4.6.3. 解壓
20.4.6.4. Creates self extracting archive.
20.5. date and time
20.5.1. 日期格式
20.5.2. -d --date=
20.5.2.1. 日期偏移量
20.5.2.2. 時間偏移
20.5.3. weekday name
20.5.4. UTC
20.6. Numeric
20.6.1. 數值運算
20.6.2. seq - print a sequence of numbers
20.6.3. bc - An arbitrary precision calculator language
20.7. Text Processing
20.7.1. iconv - Convert encoding of given files from one encoding to another
20.7.1.1. cconv - A iconv based simplified-traditional chinese conversion tool
20.7.1.2. uconv - convert data from one encoding to another
20.7.2. 字元串處理命令expr
20.7.3. cat - concatenate files and print on the standard output
20.7.3.1. -s, --squeeze-blank suppress repeated empty output lines
20.7.4. nl - number lines of files
20.7.5. od - dump files in octal and other formats
20.7.5.1. 16進制
20.7.6. tr - translate or delete characters
20.7.7. cut - remove sections from each line of files
20.7.8. printf - format and print data
20.7.9. Free `recode' converts files between various character sets and surfaces.
20.7.10. /dev/urandom 隨機字元串
20.7.11. col - filter reverse line feeds from input
20.7.12. apg - generates several random passwords
20.7.13. head/tail
20.7.14. grep, egrep, fgrep, rgrep - print lines matching a pattern
20.7.14.1. 刪除空行
20.7.14.2. -v, --invert-match
20.7.14.3. Output control
20.7.14.4. Context control
20.7.14.5. Regexp selection and interpretation
20.7.14.6. ^M
20.7.14.7. egrep
20.7.15. sort - sort lines of text files
20.7.15.1. 對列排序
20.7.16. uniq
20.7.17. 行列轉換,表格操作
20.7.17.1. column - columnate lists
20.7.17.2. paste - merge lines of files
20.7.18. 反轉字元串或檔案內容
20.8. Logging
20.8.1. logger - a shell command interface to the syslog(3) system log module
20.9. Password
20.9.1. Shadow password suite configuration.
20.9.2. newusers - update and create new users in batch
20.9.3. chpasswd - update passwords in batch mode
20.10. binutils
20.10.1. strings - print the strings of printable characters in files.
22. Utility Programs
22.1. ed, red - text editor
22.2. vim
22.2.1. 查找與替換
22.2.2. 批處理
22.2.2.1. vi 批處理
22.2.3. line()
22.3. CURL - transfer a URL
22.3.1. 基本用法
22.3.2. data
22.3.3. connect-timeout
22.3.4. compressed
22.3.5. vhosts
22.3.6. http status
22.3.7. -A/--user-agent <agent string>
22.3.8. referer
22.3.9. -v
22.3.10. -o/--output <file>
22.3.11. -H/--header <line> Custom header to pass to server (H)
22.3.11.1. Last-Modified / If-Modified-Since
22.3.11.2. ETag / If-None-Match
22.3.11.3. Accept-Encoding:gzip,defalte
22.3.11.4. HOST
22.3.11.5. HTTP 認證
22.3.12. curl-config
22.3.13. FAQ
22.4. awk
22.4.1. 處理列
22.4.2. printf
22.4.3. Pattern(字元匹配)
22.4.3.1. Pattern, Pattern
22.4.4. Built-in Variables
22.4.4.1. NR
22.4.4.2. NF
22.4.5. Built-in Functions
22.4.5.1. length
22.4.6. 過濾相同的行
22.5. sed
22.5.1. 查找與替換
22.5.1.1. 正則
22.5.1.2. delete
22.5.1.3. aaa="bbb" 提取bbb
22.5.1.4. 首字母大寫
22.5.2. 編輯檔案
22.5.3. 內容打印
22.5.4. 編輯操作
22.6. expect
22.6.1. 模擬登錄 telnet 獲取Cisco配置
22.6.2. 模擬登錄 ssh
22.6.3. SCP
22.7. expect-lite - quick and easy command line automation tool
22.8. sshpass - noninteractive ssh password provider
22.9. Klish - Kommand Line Interface Shell (the fork of clish project)
22.9.1. 安裝Klish
22.9.2. 為用戶指定clish作為預設Shell
22.9.3. FAQ
22.9.3.1. clish/shell/shell_expat.c:36:19: fatal error: expat.h: No such file or directory
22.10. Limited command Shell (lshell)
22.11. wget - retrieves files from the web
22.11.1. Logging and input file
22.11.1.1. -i, --input-file=FILE download URLs found in local or external FILE.
22.11.2. HTTP options
22.11.2.1. --post-data=STRING use the POST method; send STRING as the data.
22.11.3. Recursive download
22.11.3.1. -r, --recursive specify recursive download.
22.11.3.2. -m, --mirror shortcut for -N -r -l inf --no-remove-listing.
22.11.4. --no-passive-ftp disable the "passive" transfer mode.
22.12. TUI
22.12.1. screen - screen manager with VT100/ANSI terminal emulation
22.12.2. tmux — terminal multiplexer
22.12.3. byobu - wrapper script for seeding a user's byobu configuration and launching a text based window manager (either screen or tmux)
22.12.4. htop - interactive process viewer
22.12.5. elinks
22.12.6. chat
22.13. parallel - build and execute shell command lines from standard input in parallel
23. Shell Terminal
23.1. terminal
23.1.1. resize - set TERMCAP and terminal settings to current xterm window size
23.1.2. tset, reset - terminal initialization
23.1.3. stty - change and print terminal line settings
23.2. tput
23.2.1. Change the prompt color using tput
23.3. dialog
23.3.1. --inputbox
23.4. whiptail - display dialog boxes from shell scripts
23.4.1. --msgbox
23.4.2. --infobox
23.4.3. --yesno
23.4.4. --inputbox
23.4.5. --passwordbox
23.4.6. --textbox
23.4.7. --checklist
23.4.8. --radiolist
23.4.9. --menu
23.4.10. --gauge