Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | 雲棲社區 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Github | Search | About

部分 II. Shell

目錄

23. Bash Shell
23.1. bash - GNU Bourne-Again SHell
23.1.1. -n 檢查腳本是否有語法錯誤
23.1.2. -x 顯示詳細運行過程
23.2. Introduction
23.2.1. chsh - change login shell
23.2.2. 切換身份
23.2.3. test 命令
23.2.4. I/O 重定向
23.2.4.1. stdout
23.2.4.2. error 重定向
23.2.4.3. 使用塊記錄日誌
23.2.4.4. tee - read from standard input and write to standard output and files
23.2.4.4.1. nettee - a network "tee" program
23.2.4.5. 創建檔案
23.2.4.6. 快速清空一個檔案的內容
23.2.5. pipes (FIFOs)
23.2.6. mktemp - create a temporary file or directory 臨時目錄與檔案
23.2.7. History 命令歷史記錄
23.2.7.1. .bash_history
23.2.7.1.1. 格式定義
23.2.7.1.2. 設置忽略命令
23.2.7.2. .mysql_history
23.2.8. hash - hash database access method
23.2.9. prompt
23.3. variable
23.3.1. 系統變數
23.3.1.1. 命令行參數傳遞
23.3.1.2. $n $# $0 $?
23.3.1.3. $? 程序運行返回值
23.3.1.4. shift 移位
23.3.2. 表達式
23.3.3. Internal Environment Variables
23.3.4. set 設置變數
23.3.5. unset 變數銷毀
23.3.6. 設置變數預設值
23.3.7. export 設置全局變數
23.3.8. declare
23.3.9. Numerical 數值運算
23.3.10. Strings 字元串操作
23.3.10.1. ##/#
23.3.10.2. %%/%
23.3.10.3. :n1:n2
23.3.10.4. #
23.3.10.5. example
23.3.10.6. 計算字元串長度
23.3.10.7. 字元串查找替換
23.3.11. Array 數組
23.3.11.1. for 與 array
23.3.11.2. while 與 array
23.3.11.3. array 與 read
23.3.11.4. 拆分字元串並轉換為數組
23.3.11.5. 數組轉為字元串
23.3.12. read 賦值多個變數
23.3.13. eval
23.4. conditions if and case
23.4.1. if
23.4.2. case
23.5. Loops for, while and until
23.5.1. for
23.5.2. while
23.5.3. until
23.6. Functions
23.6.1. Local variables
23.7. User interfaces
23.7.1. input
23.8. subshell
23.9. Example
23.9.1. 有趣的Shell
23.9.2. backup
23.9.3. CPU 核心數
23.9.4. Password
23.9.5. processes
23.9.5.1. pid
23.9.5.2. kill
23.9.5.3. pgrep
23.9.6. Shell 技巧
23.9.6.1. 行轉列,再批評
23.9.6.2. for vs while
23.9.6.3. 遍歷字元串
23.9.7. to convert utf-8 from gb2312 code
23.9.8. 使用內存的百分比
23.9.9. 合併apache被cronlog分割的log檔案
23.9.10. Linux 交集 差集 並集
24. Z Shell
24.1. installing Z shell
24.2. Oh My ZSH!
24.3. Starting file
24.3.1. ~/.zshrc
24.4. Prompting
24.5. Aliases
24.6. History
24.7. FAQ
24.7.1. Home/End key
25. Berkeley UNIX C shell (csh)
25.1.
26. KornShell
26.1.
27. Shell command
27.1. Help Commands
27.1.1. man - an interface to the on-line reference manuals
27.1.1.1. manpath.config
27.1.1.2. 查看man手冊位置
27.1.1.3. 指定手冊位置
27.2. getconf - Query system configuration variables
27.3. Directory and File System Related
27.3.1. dirname
27.3.2. filename
27.3.2.1. 排除副檔名
27.3.2.2. 取副檔名
27.3.3. test - check file types and compare values
27.3.4. file — determine file type
27.3.5. stat
27.3.6. mkdir - make directories
27.3.7. rename
27.3.8. touch
27.3.9. truncate
27.3.10. ls - list directory contents
27.3.10.1. full-time / time-style 定義日期時間格式
27.3.11. cp - copy files and directories
27.3.11.1. copy directories recursively
27.3.11.2. overwrite an existing file
27.3.11.3. -a, --archive same as -dR --preserve=all
27.3.12. rm - remove files or directories
27.3.12.1. -bash: /bin/rm: Argument list too long
27.3.12.2. zsh: sure you want to delete all the files in /tmp [yn]?
27.3.13. df - report file system disk space usage
27.3.14. du - estimate file space usage
27.3.15. tac - concatenate and print files in reverse
27.3.16. split - split a file into pieces
27.3.16.1. 按行分割檔案
27.3.16.2. 按尺寸分割檔案
27.3.17. find - search for files in a directory hierarchy
27.3.17.1. name
27.3.17.2. regex
27.3.17.3. user
27.3.17.4. perm
27.3.17.5. type
27.3.17.5.1. 分別設置檔案與目錄的權限
27.3.17.6. -delete
27.3.17.7. exec
27.3.17.8. 排除目錄
27.3.17.9. -mmin n File's data was last modified n minutes ago.
27.3.17.10. -ctime
27.3.17.11. -mtime / -mmin
27.3.17.12. --newer
27.3.17.13. -print / -printf
27.3.17.14. -size
27.3.17.15. -path
27.3.17.16. -maxdepth
27.3.17.17. xargs
27.4. package / compress and decompress
27.4.1. tar — The GNU version of the tar archiving utility
27.4.1.1. tar examples
27.4.1.2. gunzip
27.4.1.3. b2zip
27.4.1.4. compress
27.4.1.5. -t, --list
27.4.1.6. tar: Removing leading `/’ from member names
27.4.1.7. -C, --directory=DIR
27.4.1.8. --exclude
27.4.1.9. -T
27.4.1.10. 日期過濾
27.4.1.11. 保留權限
27.4.1.12. -r, --append
27.4.1.13. 遠程傳輸
27.4.1.14. 分卷壓縮
27.4.2. cpio - copy files to and from archives
27.4.3. gzip
27.4.4. zip, zipcloak, zipnote, zipsplit - package and compress (archive) files
27.4.5. RAR
27.4.6. 7-Zip
27.4.6.1. 壓縮
27.4.6.2. 瀏覽壓縮包
27.4.6.3. 解壓
27.4.6.4. Creates self extracting archive.
27.4.7.
27.5. date and time
27.5.1. 日期格式
27.5.1.1. weekday name
27.5.2. -d --date=
27.5.2.1. 日期偏移量
27.5.2.1.1. day
27.5.2.1.2. month
27.5.2.1.3. year
27.5.2.2. 時間偏移
27.5.3. 時間戳
27.5.4. RFC 2822
27.5.5. UTC
27.6. Numeric
27.6.1. 數值運算
27.6.2. seq - print a sequence of numbers
27.6.3. bc - An arbitrary precision calculator language
27.7. Text Processing
27.7.1. iconv - Convert encoding of given files from one encoding to another
27.7.1.1. cconv - A iconv based simplified-traditional chinese conversion tool
27.7.1.2. uconv - convert data from one encoding to another
27.7.2. 字元串處理命令expr
27.7.3. cat - concatenate files and print on the standard output
27.7.3.1. -s, --squeeze-blank suppress repeated empty output lines
27.7.3.2. -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
27.7.4. nl - number lines of files
27.7.5. od - dump files in octal and other formats
27.7.5.1. 16進制
27.7.6. tr - translate or delete characters
27.7.7. cut - remove sections from each line of files
27.7.8. printf - format and print data
27.7.9. Free `recode' converts files between various character sets and surfaces.
27.7.10. /dev/urandom 隨機字元串
27.7.11. col - filter reverse line feeds from input
27.7.12. apg - generates several random passwords
27.7.13. head/tail
27.7.14. 反轉字元串或檔案內容
27.7.15. TAB符號與空格處理
27.7.15.1. expand - convert tabs to spaces
27.7.15.2. unexpand - convert spaces to tabs
27.8. grep, egrep, fgrep, rgrep - print lines matching a pattern
27.8.1. 刪除空行
27.8.2. -v, --invert-match
27.8.3. Output control
27.8.3.1. -o, --only-matching show only the part of a line matching PATTERN
27.8.3.1.1. IP 地址
27.8.3.1.2. UUID
27.8.3.2. 遞歸操作
27.8.3.3. -c, --count print only a count of matching lines per FILE
27.8.4. Context control
27.8.4.1. -A, --after-context=NUM print NUM lines of trailing context
27.8.4.2. -B, --before-context=NUM print NUM lines of leading context
27.8.4.3. -C, --context=NUM print NUM lines of output context
27.8.4.4. --color
27.8.5. Regexp selection and interpretation
27.8.5.1. .*
27.8.5.2. 2010:(13|14|15|16)
27.8.5.3. []與{}
27.8.5.4. -P, --perl-regexp Perl正則表達式
27.8.6. fgrep
27.8.7. egrep
27.9. sort - sort lines of text files
27.9.1. 對列排序
27.9.2. -s, --stable stabilize sort by disabling last-resort comparison
27.10. uniq
27.11. 表格操作/行列轉換
27.11.1. column - columnate lists
27.11.2. paste - merge lines of files
27.11.3. join
27.12. standard input/output
27.12.1. xargs - build and execute command lines from standard input
27.12.1.1. 格式化
27.12.1.2. standard input
27.12.1.3. -I 替換操作
27.12.1.4. -n, --max-args=MAX-ARGS use at most MAX-ARGS arguments per command line
27.12.1.5. -t, --verbose print commands before executing them
27.12.1.6. -d, --delimiter=CHARACTER items in input stream are separated by CHARACTER, not by whitespace; disables quote and backslash processing and logical EOF processing
27.12.1.7. -0, --null items are separated by a null, not whitespace; disables quote and backslash processing and logical EOF processing
27.12.1.8. -r, --no-run-if-empty if there are no arguments, then do not run COMMAND; if this option is not given, COMMAND will be
27.12.1.9. -p, --interactive prompt before running commands
27.13. flock - manage locks from shell scripts
27.14. Logging
27.14.1. logger - a shell command interface to the syslog(3) system log module
27.15. Password
27.15.1. Shadow password suite configuration.
27.15.2. newusers - update and create new users in batch
27.15.3. chpasswd - update passwords in batch mode
27.16. binutils
27.16.1. strings - print the strings of printable characters in files.
29. Utility Programs
29.1. ed, red - text editor
29.2. vim
29.2.1. 查找與替換
29.2.2. 插入檔案
29.2.3. 批處理
29.2.3.1. vi 批處理
29.2.4. line()
29.2.5. set fileformat
29.3. awk
29.3.1. 處理列
29.3.2. printf
29.3.3. Pattern(字元匹配)
29.3.3.1. Pattern, Pattern
29.3.4. Built-in Variables (NR/NF)
29.3.4.1. NR
29.3.4.2. NF
29.3.4.3. 練習
29.3.4.3.1. 使用 ss 命令統計 TCP 狀態
29.3.4.3.2. TCP/IP Status
29.3.4.3.3. 用戶shell統計
29.3.4.3.4. access.log POST與GET統計
29.3.5. Built-in Functions
29.3.5.1. length
29.3.6. 過濾相同的行
29.4. sed
29.4.1. 查找與替換
29.4.1.1. 正則
29.4.1.2. aaa="bbb" 提取bbb
29.4.1.3. 首字母大寫
29.4.2. insert 插入字元
29.4.3. 追加字元
29.4.4. 修改字元
29.4.5. 刪除字元
29.4.5.1. delete
29.4.6. 行操作
29.4.7. 編輯檔案
29.4.8. 正則表達式
29.4.9. 管道操作
29.4.10. perl
29.5. CURL - transfer a URL
29.5.1. 基本用法
29.5.2. data
29.5.3. connect-timeout
29.5.4. max-time
29.5.5. compressed
29.5.6. vhosts
29.5.7. -w, --write-out <format> 輸出格式定義
29.5.8. -A/--user-agent <agent string>
29.5.9. referer
29.5.10. -v
29.5.11. -o, --output FILE Write output to <file> instead of stdout
29.5.12. -H/--header <line> Custom header to pass to server (H)
29.5.12.1. Last-Modified / If-Modified-Since
29.5.12.2. ETag / If-None-Match
29.5.12.3. Accept-Encoding:gzip,defalte
29.5.12.4. HOST
29.5.12.5. HTTP 認證
29.5.12.6. Accept
29.5.12.7. Content-Type
29.5.13. curl-config
29.5.14. 指定網絡介面或者地址
29.5.15. Cookie 處理
29.5.16. RestFul 應用 JSON 數據處理
29.5.17. FAQ
29.6. expect
29.6.1. 模擬登錄 telnet 獲取Cisco配置
29.6.2. 模擬登錄 ssh
29.6.3. SCP
29.7. expect-lite - quick and easy command line automation tool
29.8. sshpass - noninteractive ssh password provider
29.9. Klish - Kommand Line Interface Shell (the fork of clish project)
29.9.1. 安裝Klish
29.9.2. 為用戶指定clish作為預設Shell
29.9.3. FAQ
29.9.3.1. clish/shell/shell_expat.c:36:19: fatal error: expat.h: No such file or directory
29.10. Limited command Shell (lshell)
29.11. wget - retrieves files from the web
29.11.1. Logging and input file
29.11.1.1. -i, --input-file=FILE download URLs found in local or external FILE.
29.11.2. 下載相關參數
29.11.2.1. -O, --output-document=FILE write documents to FILE 保存到檔案
29.11.3. HTTP options (HTTP 選項)
29.11.3.1. --post-data=STRING use the POST method; send STRING as the data.
29.11.3.2. header HTTP頭定義
29.11.4. Recursive download
29.11.4.1. -r, --recursive specify recursive download.
29.11.4.2. -m, --mirror shortcut for -N -r -l inf --no-remove-listing.
29.11.5. --no-passive-ftp disable the "passive" transfer mode.
29.12. TUI
29.12.1. screen - screen manager with VT100/ANSI terminal emulation
29.12.2. tmux — terminal multiplexer
29.12.3. byobu - wrapper script for seeding a user's byobu configuration and launching a text based window manager (either screen or tmux)
29.12.4. htop - interactive process viewer
29.12.5. elinks
29.12.6. chat
29.13. parallel - build and execute shell command lines from standard input in parallel
30. Shell Terminal
30.1. terminal
30.1.1. resize - set TERMCAP and terminal settings to current xterm window size
30.1.2. tset, reset - terminal initialization
30.1.3. stty - change and print terminal line settings
30.2. tput
30.2.1. Change the prompt color using tput
30.3. dialog
30.3.1. --inputbox
30.4. whiptail - display dialog boxes from shell scripts
30.4.1. --msgbox
30.4.2. --infobox
30.4.3. --yesno
30.4.4. --inputbox
30.4.5. --passwordbox
30.4.6. --textbox
30.4.7. --checklist
30.4.8. --radiolist
30.4.9. --menu
30.4.10. --gauge