Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

部分 II. Shell

目錄

22. Bash Shell
22.1. bash - GNU Bourne-Again SHell
22.1.1. -n 檢查腳本是否有語法錯誤
22.1.2. -x 顯示詳細運行過程
22.2. Introduction
22.2.1. chsh - change login shell
22.2.2. 切換身份
22.2.3. test 命令
22.2.4. I/O 重定向
22.2.4.1. error 重定向
22.2.4.2. 使用塊記錄日誌
22.2.4.3. tee - read from standard input and write to standard output and files
22.2.4.4. 創建檔案
22.2.4.5. 快速清空一個檔案的內容
22.2.5. pipes (FIFOs)
22.2.6. mktemp - create a temporary file or directory 臨時目錄與檔案
22.2.7. History 命令歷史記錄
22.2.7.1. .bash_history
22.2.7.2. .mysql_history
22.2.8. hash - hash database access method
22.2.9. prompt
22.3. variable
22.3.1. 系統變數
22.3.1.1. 命令行參數傳遞
22.3.1.2. $n $# $0 $?
22.3.1.3. shift 移位
22.3.2. 表達式
22.3.3. Internal Environment Variables
22.3.4. set 設置變數
22.3.5. unset 變數銷毀
22.3.6. 設置變數預設值
22.3.7. export 設置全局變數
22.3.8. declare
22.3.9. Numerical 數值運算
22.3.10. Strings 字元串操作
22.3.10.1. ##/#
22.3.10.2. %%/%
22.3.10.3. :n1:n2
22.3.10.4. #
22.3.10.5. example
22.3.10.6. 計算字元串長度
22.3.10.7. 字元串查找替換
22.3.11. Array 數組
22.3.11.1. for 與 array
22.3.11.2. while 與 array
22.3.11.3. array 與 read
22.3.11.4. 拆分字元串並轉換為數組
22.3.11.5. 數組轉為字元串
22.3.12. read 賦值多個變數
22.3.13. eval
22.4. conditions if and case
22.4.1. if
22.4.2. case
22.5. Loops for, while and until
22.5.1. for
22.5.2. while
22.5.3. until
22.6. Functions
22.6.1. Local variables
22.7. User interfaces
22.7.1. input
22.8. subshell
22.9. Example
22.9.1. 有趣的Shell
22.9.2. backup
22.9.3. CPU 核心數
22.9.4. Password
22.9.5. processes
22.9.5.1. pid
22.9.5.2. kill
22.9.5.3. pgrep
22.9.6. Shell 技巧
22.9.6.1. 行轉列,再批評
22.9.6.2. for vs while
22.9.6.3. 遍歷字元串
22.9.7. to convert utf-8 from gb2312 code
22.9.8. 使用內存的百分比
22.9.9. 合併apache被cronlog分割的log檔案
23. Z Shell
23.1. installing Z shell
23.2. Starting file
23.2.1. ~/.zshrc
23.3. Prompting
23.4. Aliases
23.5. History
23.6. FAQ
23.6.1. Home/End key
24. Shell command
24.1. Help Commands
24.1.1. man - an interface to the on-line reference manuals
24.1.1.1. manpath.config
24.1.1.2. 查看man手冊位置
24.1.1.3. 指定手冊位置
24.2. getconf - Query system configuration variables
24.3. Directory and File System Related
24.3.1. dirname
24.3.2. filename
24.3.2.1. 排除副檔名
24.3.2.2. 取副檔名
24.3.3. test - check file types and compare values
24.3.4. stat
24.3.5. mkdir - make directories
24.3.6. rename
24.3.7. touch
24.3.8. ls - list directory contents
24.3.8.1. full-time / time-style 定義日期時間格式
24.3.9. cp - copy files and directories
24.3.9.1. copy directories recursively
24.3.9.2. overwrite an existing file
24.3.9.3. -a, --archive same as -dR --preserve=all
24.3.10. rm - remove files or directories
24.3.10.1. -bash: /bin/rm: Argument list too long
24.3.10.2. zsh: sure you want to delete all the files in /tmp [yn]?
24.3.11. df - report file system disk space usage
24.3.12. du - estimate file space usage
24.3.13. tac - concatenate and print files in reverse
24.3.14. split - split a file into pieces
24.3.14.1. 按行分割檔案
24.3.14.2. 按尺寸分割檔案
24.3.15. find - search for files in a directory hierarchy
24.3.15.1. name
24.3.15.2. regex
24.3.15.3. user
24.3.15.4. perm
24.3.15.5. type
24.3.15.6. -delete
24.3.15.7. exec
24.3.15.8. xargs
24.3.15.9. 排除目錄
24.3.15.10. -mmin n File's data was last modified n minutes ago.
24.3.15.11. -mtime / -mmin
24.3.15.12. --newer
24.3.15.13. -print / -printf
24.3.15.14. -size
24.4. package / compress and decompress
24.4.1. tar — The GNU version of the tar archiving utility
24.4.1.1. tar examples
24.4.1.2. gunzip
24.4.1.3. b2zip
24.4.1.4. compress
24.4.1.5. -t, --list
24.4.1.6. tar: Removing leading `/’ from member names
24.4.1.7. -C, --directory=DIR
24.4.1.8. -P, --absolute-names don't strip leading `/'s from file names
24.4.1.9. --exclude
24.4.1.10. -T
24.4.1.11. 日期過濾
24.4.1.12. 保留權限
24.4.1.13. -r, --append
24.4.1.14. 遠程傳輸
24.4.1.15. 分卷壓縮
24.4.2. cpio - copy files to and from archives
24.4.3. gzip
24.4.4. zip, zipcloak, zipnote, zipsplit - package and compress (archive) files
24.4.5. RAR
24.4.6. 7-Zip
24.4.6.1. 壓縮
24.4.6.2. 瀏覽壓縮包
24.4.6.3. 解壓
24.4.6.4. Creates self extracting archive.
24.5. date and time
24.5.1. 日期格式
24.5.2. -d --date=
24.5.2.1. 日期偏移量
24.5.2.2. 時間偏移
24.5.3. weekday name
24.5.4. UTC
24.6. Numeric
24.6.1. 數值運算
24.6.2. seq - print a sequence of numbers
24.6.3. bc - An arbitrary precision calculator language
24.7. Text Processing
24.7.1. iconv - Convert encoding of given files from one encoding to another
24.7.1.1. cconv - A iconv based simplified-traditional chinese conversion tool
24.7.1.2. uconv - convert data from one encoding to another
24.7.2. 字元串處理命令expr
24.7.3. cat - concatenate files and print on the standard output
24.7.3.1. -s, --squeeze-blank suppress repeated empty output lines
24.7.4. nl - number lines of files
24.7.5. od - dump files in octal and other formats
24.7.5.1. 16進制
24.7.6. tr - translate or delete characters
24.7.7. cut - remove sections from each line of files
24.7.8. printf - format and print data
24.7.9. Free `recode' converts files between various character sets and surfaces.
24.7.10. /dev/urandom 隨機字元串
24.7.11. col - filter reverse line feeds from input
24.7.12. apg - generates several random passwords
24.7.13. head/tail
24.7.14. 反轉字元串或檔案內容
24.8. grep, egrep, fgrep, rgrep - print lines matching a pattern
24.8.1. 刪除空行
24.8.2. -v, --invert-match
24.8.3. Output control
24.8.3.1. -o, --only-matching show only the part of a line matching PATTERN
24.8.3.2. 遞歸操作
24.8.3.3. -c, --count print only a count of matching lines per FILE
24.8.4. Context control
24.8.4.1. -A, --after-context=NUM print NUM lines of trailing context
24.8.4.2. -B, --before-context=NUM print NUM lines of leading context
24.8.4.3. -C, --context=NUM print NUM lines of output context
24.8.4.4. --color
24.8.5. Regexp selection and interpretation
24.8.5.1. .*
24.8.5.2. 2010:(13|14|15|16)
24.8.5.3. []與{}
24.8.5.4. -P, --perl-regexp Perl正則表達式
24.8.6. fgrep
24.8.7. egrep
24.9. sort - sort lines of text files
24.9.1. 對列排序
24.10. uniq
24.11. 表格操作/行列轉換
24.11.1. column - columnate lists
24.11.2. paste - merge lines of files
24.12. standard input/output
24.12.1. xargs - build and execute command lines from standard input
24.12.1.1. 格式化
24.12.1.2. standard input
24.12.1.3. -I 替換操作
24.13. Logging
24.13.1. logger - a shell command interface to the syslog(3) system log module
24.14. Password
24.14.1. Shadow password suite configuration.
24.14.2. newusers - update and create new users in batch
24.14.3. chpasswd - update passwords in batch mode
24.15. binutils
24.15.1. strings - print the strings of printable characters in files.
26. Utility Programs
26.1. ed, red - text editor
26.2. vim
26.2.1. 查找與替換
26.2.2. 插入檔案
26.2.3. 批處理
26.2.3.1. vi 批處理
26.2.4. line()
26.3. awk
26.3.1. 處理列
26.3.2. printf
26.3.3. Pattern(字元匹配)
26.3.3.1. Pattern, Pattern
26.3.4. Built-in Variables (NR/NF)
26.3.4.1. NR
26.3.4.2. NF
26.3.4.3. 練習
26.3.5. Built-in Functions
26.3.5.1. length
26.3.6. 過濾相同的行
26.4. sed
26.4.1. 查找與替換
26.4.1.1. 正則
26.4.1.2. delete
26.4.1.3. aaa="bbb" 提取bbb
26.4.1.4. 首字母大寫
26.4.2. 編輯檔案
26.4.3. 內容打印
26.4.4. 編輯操作
26.4.4.1. insert
26.4.5. 管道操作
26.5. CURL - transfer a URL
26.5.1. 基本用法
26.5.2. data
26.5.3. connect-timeout
26.5.4. max-time
26.5.5. compressed
26.5.6. vhosts
26.5.7. 輸出格式定義
26.5.8. -A/--user-agent <agent string>
26.5.9. referer
26.5.10. -v
26.5.11. -o, --output FILE Write output to <file> instead of stdout
26.5.12. -H/--header <line> Custom header to pass to server (H)
26.5.12.1. Last-Modified / If-Modified-Since
26.5.12.2. ETag / If-None-Match
26.5.12.3. Accept-Encoding:gzip,defalte
26.5.12.4. HOST
26.5.12.5. HTTP 認證
26.5.13. curl-config
26.5.14. FAQ
26.6. expect
26.6.1. 模擬登錄 telnet 獲取Cisco配置
26.6.2. 模擬登錄 ssh
26.6.3. SCP
26.7. expect-lite - quick and easy command line automation tool
26.8. sshpass - noninteractive ssh password provider
26.9. Klish - Kommand Line Interface Shell (the fork of clish project)
26.9.1. 安裝Klish
26.9.2. 為用戶指定clish作為預設Shell
26.9.3. FAQ
26.9.3.1. clish/shell/shell_expat.c:36:19: fatal error: expat.h: No such file or directory
26.10. Limited command Shell (lshell)
26.11. wget - retrieves files from the web
26.11.1. Logging and input file
26.11.1.1. -i, --input-file=FILE download URLs found in local or external FILE.
26.11.2. HTTP options
26.11.2.1. --post-data=STRING use the POST method; send STRING as the data.
26.11.3. Recursive download
26.11.3.1. -r, --recursive specify recursive download.
26.11.3.2. -m, --mirror shortcut for -N -r -l inf --no-remove-listing.
26.11.4. --no-passive-ftp disable the "passive" transfer mode.
26.12. TUI
26.12.1. screen - screen manager with VT100/ANSI terminal emulation
26.12.2. tmux — terminal multiplexer
26.12.3. byobu - wrapper script for seeding a user's byobu configuration and launching a text based window manager (either screen or tmux)
26.12.4. htop - interactive process viewer
26.12.5. elinks
26.12.6. chat
26.13. parallel - build and execute shell command lines from standard input in parallel
27. Shell Terminal
27.1. terminal
27.1.1. resize - set TERMCAP and terminal settings to current xterm window size
27.1.2. tset, reset - terminal initialization
27.1.3. stty - change and print terminal line settings
27.2. tput
27.2.1. Change the prompt color using tput
27.3. dialog
27.3.1. --inputbox
27.4. whiptail - display dialog boxes from shell scripts
27.4.1. --msgbox
27.4.2. --infobox
27.4.3. --yesno
27.4.4. --inputbox
27.4.5. --passwordbox
27.4.6. --textbox
27.4.7. --checklist
27.4.8. --radiolist
27.4.9. --menu
27.4.10. --gauge