Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | Email

Netkiller Linux Shell 手札

Mr. Neo Chan, 陈景峯(BG7NYT)


中国广东省深圳市龙华新区民治街道溪山美地
518131
+86 13113668890


2009-11-15

版权声明

转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。

文档出处:
http://netkiller.github.io
http://netkiller.sourceforge.net

微信扫描二维码进入 Netkiller 微信订阅号

QQ群:128659835 请注明“读者”


目录

1. 自述
1.1. 系列文档
1.2. 作者简介
1.3. 写给读者
1.4. 文档下载
1. Bash Shell
1.1. bash - GNU Bourne-Again SHell
1.1.1. -n 检查脚本是否有语法错误
1.1.2. -x 显示详细运行过程
1.2. Introduction
1.2.1. chsh - change login shell
1.2.2. test 命令
1.2.3. I/O 重定向
1.2.3.1. error 重定向
1.2.3.2. 使用块记录日志
1.2.3.3. tee - read from standard input and write to standard output and files
1.2.3.4. 创建文件
1.2.3.5. 快速清空一个文件的内容
1.2.4. pipes (FIFOs)
1.2.5. mktemp - create a temporary file or directory 临时目录与文件
1.2.6. History 命令历史记录
1.2.6.1. .bash_history
1.2.6.2. .mysql_history
1.2.7. hash - hash database access method
1.2.8. prompt
1.3. variable
1.3.1. 表达式
1.3.2. Internal Environment Variables
1.3.3. set 设置变量
1.3.4. unset 变量销毁
1.3.5. 设置变量默认值
1.3.6. export 设置全局变量
1.3.7. declare
1.3.8. 系统变量
1.3.9. Numerical 数值运算
1.3.10. Strings 字符串操作
1.3.10.1. ##/#
1.3.10.2. %%/%
1.3.10.3. :n1:n2
1.3.10.4. #
1.3.10.5. example
1.3.10.6. 计算字符串长度
1.3.10.7. 字符串查找替换
1.3.11. Array 数组
1.3.11.1. 拆分字符串并转换为数组
1.3.11.2. 数组转为字符串
1.3.12. eval
1.4. conditions if and case
1.4.1. if
1.4.2. case
1.5. Loops for, while and until
1.5.1. for
1.5.2. while
1.5.3. until
1.6. Functions
1.6.1. Local variables
1.7. User interfaces
1.7.1. input
1.8. Example
1.8.1. 有趣的Shell
1.8.2. backup
1.8.3. CPU 核心数
1.8.4. Password
1.8.5. processes
1.8.5.1. pid
1.8.5.2. kill
1.8.5.3. pgrep
1.8.6. Shell 技巧
1.8.6.1. 行转列,再批评
1.8.6.2. for vs while
1.8.6.3. 遍历字符串
1.8.7. to convert utf-8 from gb2312 code
1.8.8. 使用内存的百分比
1.8.9. 合并apache被cronlog分割的log文件
2. Z Shell
2.1. installing Z shell
2.2. Starting file
2.2.1. ~/.zshrc
2.3. Prompting
2.4. Aliases
2.5. History
2.6. FAQ
2.6.1. Home/End key
3. Shell command
3.1. Help Commands
3.1.1. man - an interface to the on-line reference manuals
3.1.1.1. manpath.config
3.1.1.2. 查看man手册位置
3.1.1.3. 指定手册位置
3.2. getconf - Query system configuration variables
3.3. Directory and File System Related
3.3.1. dirname
3.3.2. filename
3.3.2.1. 排除扩展名
3.3.2.2. 取扩展名
3.3.3. test - check file types and compare values
3.3.4. stat
3.3.5. mkdir - make directories
3.3.6. rename
3.3.7. touch
3.3.8. ls - list directory contents
3.3.8.1. full-time / time-style 定义日期时间格式
3.3.9. cp - copy files and directories
3.3.9.1. copy directories recursively
3.3.9.2. overwrite an existing file
3.3.9.3. -a, --archive same as -dR --preserve=all
3.3.10. rm - remove files or directories
3.3.10.1. -bash: /bin/rm: Argument list too long
3.3.10.2. zsh: sure you want to delete all the files in /tmp [yn]?
3.3.11. df - report file system disk space usage
3.3.12. du - estimate file space usage
3.3.13. tac - concatenate and print files in reverse
3.3.14. split - split a file into pieces
3.3.14.1. 按行分割文件
3.3.14.2. 按尺寸分割文件
3.3.15. find - search for files in a directory hierarchy
3.3.15.1. name
3.3.15.2. regex
3.3.15.3. user
3.3.15.4. perm
3.3.15.5. type
3.3.15.6. -delete
3.3.15.7. exec
3.3.15.8. xargs
3.3.15.9. 排除目录
3.3.15.10. -mtime / -mmin
3.3.15.11. --newer
3.3.15.12. -print / -printf
3.3.15.13. -size
3.4. package / compress and decompress
3.4.1. tar — The GNU version of the tar archiving utility
3.4.1.1. tar examples
3.4.1.2. gunzip
3.4.1.3. b2zip
3.4.1.4. compress
3.4.1.5. -t, --list
3.4.1.6. tar: Removing leading `/’ from member names
3.4.1.7. -C, --directory=DIR
3.4.1.8. -P, --absolute-names don't strip leading `/'s from file names
3.4.1.9. --exclude
3.4.1.10. -T
3.4.1.11. 日期过滤
3.4.1.12. 保留权限
3.4.1.13. -r, --append
3.4.1.14. 远程传输
3.4.1.15. 分卷压缩
3.4.2. cpio - copy files to and from archives
3.4.3. gzip
3.4.4. zip, zipcloak, zipnote, zipsplit - package and compress (archive) files
3.4.5. RAR
3.4.6. 7-Zip
3.4.6.1. 压缩
3.4.6.2. 浏览压缩包
3.4.6.3. 解压
3.4.6.4. Creates self extracting archive.
3.5. date and time
3.5.1. 日期格式
3.5.2. -d --date=
3.5.2.1. 日期偏移量
3.5.2.2. 时间偏移
3.5.3. weekday name
3.5.4. UTC
3.6. Numeric
3.6.1. 数值运算
3.6.2. seq - print a sequence of numbers
3.6.3. bc - An arbitrary precision calculator language
3.7. Text Processing
3.7.1. iconv - Convert encoding of given files from one encoding to another
3.7.1.1. cconv - A iconv based simplified-traditional chinese conversion tool
3.7.1.2. uconv - convert data from one encoding to another
3.7.2. 字符串处理命令expr
3.7.3. cat - concatenate files and print on the standard output
3.7.3.1. -s, --squeeze-blank suppress repeated empty output lines
3.7.4. nl - number lines of files
3.7.5. od - dump files in octal and other formats
3.7.5.1. 16进制
3.7.6. tr - translate or delete characters
3.7.7. cut - remove sections from each line of files
3.7.8. printf - format and print data
3.7.9. Free `recode' converts files between various character sets and surfaces.
3.7.10. /dev/urandom 随机字符串
3.7.11. col - filter reverse line feeds from input
3.7.12. apg - generates several random passwords
3.7.13. head/tail
3.7.14. grep, egrep, fgrep, rgrep - print lines matching a pattern
3.7.14.1. 删除空行
3.7.14.2. -v, --invert-match
3.7.14.3. Output control
3.7.14.4. Context control
3.7.14.5. Regexp selection and interpretation
3.7.14.6. fgrep
3.7.14.7. egrep
3.7.15. sort - sort lines of text files
3.7.15.1. 对列排序
3.7.16. uniq
3.7.17. 行列转换,表格操作
3.7.17.1. column - columnate lists
3.7.17.2. paste - merge lines of files
3.7.18. 反转字符串或文件内容
3.8. Logging
3.8.1. logger - a shell command interface to the syslog(3) system log module
3.9. Password
3.9.1. Shadow password suite configuration.
3.9.2. newusers - update and create new users in batch
3.9.3. chpasswd - update passwords in batch mode
3.10. binutils
3.10.1. strings - print the strings of printable characters in files.
5. Utility Programs
5.1. ed, red - text editor
5.2. vim
5.2.1. 查找与替换
5.2.2. 批处理
5.2.2.1. vi 批处理
5.2.3. line()
5.3. CURL - transfer a URL
5.3.1. 基本用法
5.3.2. data
5.3.3. connect-timeout
5.3.4. compressed
5.3.5. vhosts
5.3.6. 输出格式定义
5.3.7. -A/--user-agent <agent string>
5.3.8. referer
5.3.9. -v
5.3.10. -o/--output <file>
5.3.11. -H/--header <line> Custom header to pass to server (H)
5.3.11.1. Last-Modified / If-Modified-Since
5.3.11.2. ETag / If-None-Match
5.3.11.3. Accept-Encoding:gzip,defalte
5.3.11.4. HOST
5.3.11.5. HTTP 认证
5.3.12. curl-config
5.3.13. FAQ
5.4. awk
5.4.1. 处理列
5.4.2. printf
5.4.3. Pattern(字符匹配)
5.4.3.1. Pattern, Pattern
5.4.4. Built-in Variables
5.4.4.1. NR
5.4.4.2. NF
5.4.5. Built-in Functions
5.4.5.1. length
5.4.6. 过滤相同的行
5.5. sed
5.5.1. 查找与替换
5.5.1.1. 正则
5.5.1.2. delete
5.5.1.3. aaa="bbb" 提取bbb
5.5.1.4. 首字母大写
5.5.2. 编辑文件
5.5.3. 内容打印
5.5.4. 编辑操作
5.6. expect
5.6.1. 模拟登录 telnet 获取Cisco配置
5.6.2. 模拟登录 ssh
5.6.3. SCP
5.7. expect-lite - quick and easy command line automation tool
5.8. sshpass - noninteractive ssh password provider
5.9. Klish - Kommand Line Interface Shell (the fork of clish project)
5.9.1. 安装Klish
5.9.2. 为用户指定clish作为默认Shell
5.9.3. FAQ
5.9.3.1. clish/shell/shell_expat.c:36:19: fatal error: expat.h: No such file or directory
5.10. Limited command Shell (lshell)
5.11. wget - retrieves files from the web
5.11.1. Logging and input file
5.11.1.1. -i, --input-file=FILE download URLs found in local or external FILE.
5.11.2. HTTP options
5.11.2.1. --post-data=STRING use the POST method; send STRING as the data.
5.11.3. Recursive download
5.11.3.1. -r, --recursive specify recursive download.
5.11.3.2. -m, --mirror shortcut for -N -r -l inf --no-remove-listing.
5.11.4. --no-passive-ftp disable the "passive" transfer mode.
5.12. TUI
5.12.1. screen - screen manager with VT100/ANSI terminal emulation
5.12.2. tmux — terminal multiplexer
5.12.3. byobu - wrapper script for seeding a user's byobu configuration and launching a text based window manager (either screen or tmux)
5.12.4. htop - interactive process viewer
5.12.5. elinks
5.12.6. chat
5.13. parallel - build and execute shell command lines from standard input in parallel
6. Shell Terminal
6.1. terminal
6.1.1. resize - set TERMCAP and terminal settings to current xterm window size
6.1.2. tset, reset - terminal initialization
6.1.3. stty - change and print terminal line settings
6.2. tput
6.2.1. Change the prompt color using tput
6.3. dialog
6.3.1. --inputbox
6.4. whiptail - display dialog boxes from shell scripts
6.4.1. --msgbox
6.4.2. --infobox
6.4.3. --yesno
6.4.4. --inputbox
6.4.5. --passwordbox
6.4.6. --textbox
6.4.7. --checklist
6.4.8. --radiolist
6.4.9. --menu
6.4.10. --gauge
1. 附录
1.1. 参考文献

表格清单

1.1. 文件目录表达式
1.2. 字符串表达式
1.3. 组合表达式

范例清单

1.1. A "Power User" Prompt
1.2. A Prompt the Width of Your Term
1.3. The Elegant Useless Clock Prompt
1.4. Basic conditional example if .. then
1.5. Conditionals with variables
1.6. case
1.7. Functions with parameters sample
1.8. Using select to make simple menus
1.9. Using the command line
1.10. Reading user input with read
1.11. read
1.12. random password
3.1. backup(find + tar)
5.1. example for expect
5.2. example for expect
5.3. example 1
5.4. *.exp
5.5. parallel - build and execute shell command lines from standard input in parallel
6.1. whiptail - yesno
6.2. whiptail - inputbox
6.3. whiptail - passwordbox
6.4. whiptail - passwordbox
6.5. whiptail - example 1
6.6. whiptail - radiolist
comments powered by Disqus