Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

部分 II. Shell

目录

19. Bash Shell
19.1. bash - GNU Bourne-Again SHell
19.1.1. -n 检查脚本是否有语法错误
19.1.2. -x 显示详细运行过程
19.2. 切换身份
19.3. I/O 重定向
19.3.1. stdout
19.3.2. error 重定向
19.3.3. 使用块记录日志
19.3.4. test - 条件判断命令
19.3.5. tee - read from standard input and write to standard output and files
19.3.6. 创建文件
19.3.7. 快速清空一个文件的内容
19.4. pipes (FIFOs)
19.5. mktemp - create a temporary file or directory 临时目录与文件
19.6. History 命令历史记录
19.6.1. .bash_history
19.6.2. 清理历史记录
19.6.3. .mysql_history
19.7. hash - hash database access method
19.8. prompt
19.9. 变量 variable
19.9.1. 系统变量
19.9.2. 表达式
19.9.3. Internal Environment Variables
19.9.4. set 设置变量
19.9.5. unset 变量销毁
19.9.6. 设置变量默认值
19.9.7. export 设置全局变量
19.9.8. declare
19.9.9. Numerical 数值运算
19.9.10. Strings 字符串操作
19.9.11. Array 数组
19.9.12. read 赋值多个变量
19.9.13. eval
19.9.14. typeset
19.9.15. envsubst - substitutes environment variables in shell format strings
19.10. conditions if and case
19.10.1. if
19.10.2. case
19.11. Loops for, while and until
19.11.1. for
19.11.2. while
19.11.3. until
19.12. Functions
19.12.1. Local variables
19.13. User interfaces
19.13.1. input
19.14. subshell
19.15. Help Commands
19.15.1. man - an interface to the on-line reference manuals
19.16. getconf - Query system configuration variables
19.17. 快捷键
19.17.1. 命令行编辑命令
19.17.2. 重新执行命令快捷键
19.17.3. 终端控制快捷键
19.17.4. Bang (!) 命令
19.18. chsh - change login shell
19.19. 执行程序返回值
19.20. Z Shell
19.20.1. installing Z shell
19.20.2. Oh My ZSH!
19.20.3. Starting file
19.20.4. Prompting
19.20.5. Aliases
19.20.6. History
19.20.7. FAQ
19.21. Berkeley UNIX C shell (csh)
19.21.1.
19.22. KornShell
19.22.1.
19.23. fish shell
19.23.1. 安装 fish shell
19.23.2. 配置 fish
19.23.3. 环境变量
19.24. 有趣的 Shell 应用
19.24.1. Ascii 星球大战电影
19.24.2. 天气预报
19.24.3. htop - interactive process viewer
19.24.4. elinks
19.24.5. chat
19.25. Example
19.25.1. 有趣的Shell
19.25.2. backup
19.25.3. CPU 核心数
19.25.4. Password
19.25.5. processes
19.25.6. Shell 技巧
19.25.7. to convert utf-8 from gb2312 code
19.25.8. 使用内存的百分比
19.25.9. 合并apache被cronlog分割的log文件
19.25.10. Linux 交集 差集 并集
20. 目录和文件
20.1. dirname - 提取目录部分
20.2. basename - 提取文件名部分
20.2.1. 排除扩展名
20.2.2. 取扩展名
20.3. file — determine file type
20.4. stat
20.5. file – determine file type
20.6. mkdir - make directories
20.7. rename
20.8. touch
20.9. truncate
20.10. ls - list directory contents
20.10.1. full-time / time-style 定义日期时间格式
20.11. cp - copy files and directories
20.11.1. copy directories recursively
20.11.2. 覆盖已存在的文件
20.11.3. -a, --archive same as -dR --preserve=all
20.12. rm - remove files or directories
20.12.1. -bash: /bin/rm: Argument list too long
20.12.2. zsh: sure you want to delete all the files in /tmp [yn]?
20.13. df - report file system disk space usage
20.14. du - estimate file space usage
20.15. tac - concatenate and print files in reverse
20.16. split - split a file into pieces
20.16.1. 按行分割文件
20.16.2. 按尺寸分割文件
20.17. find - search for files in a directory hierarchy
20.17.1. 多目录匹配
20.17.2. name
20.17.3. regex
20.17.4. user
20.17.5. perm
20.17.6. type
20.17.7. -delete
20.17.8. exec
20.17.9. 排除目录
20.17.10. -ctime / -cmin - 按状态改变时间查找
20.17.11. -mtime / -mmin - 按修改时间查找
20.17.12. --newer
20.17.13. -print / -printf
20.17.14. -size
20.17.15. -path
20.17.16. 目录深度控制
20.17.17. xargs
20.17.18. 查看空文件
21. 包管理 / 压缩 / 解压
21.1. tar — The GNU version of the tar archiving utility
21.1.1. tar examples
21.1.2. gunzip
21.1.3. b2zip
21.1.4. compress
21.1.5. .xz 文件
21.1.6. -t, --list
21.1.7. tar: Removing leading `/’ from member names
21.1.8. -C, --directory=DIR
21.1.9. --exclude
21.1.10. -T
21.1.11. 日期过滤
21.1.12. 保留权限
21.1.13. -r, --append
21.1.14. 远程传输
21.1.15. 分卷压缩
21.2. cpio - copy files to and from archives
21.3. gzip
21.4. zip, zipcloak, zipnote, zipsplit - package and compress (archive) files
21.5. bzip2, bunzip2 - a block-sorting file compressor
21.6. RAR
21.7. 7-Zip
21.7.1. 压缩
21.7.2. 浏览压缩包
21.7.3. 解压
21.7.4. Creates self extracting archive.
21.8. RAR
21.9. xz, unxz, xzcat, lzma, unlzma, lzcat - Compress or decompress .xz and .lzma files
22. 日期和时间
22.1. 日期格式
22.1.1. weekday name
22.2. -d --date=
22.2.1. 日期偏移量
22.2.2. 时间偏移
22.3. 时间戳
22.4. RFC 2822
22.5. UTC
22.6. 字符串转日期
23. 数值与运算
23.1. 数值运算
23.2. seq - print a sequence of numbers
23.3. bc - An arbitrary precision calculator language
24. 文本处理
24.1. iconv - Convert encoding of given files from one encoding to another
24.1.1. cconv - A iconv based simplified-traditional chinese conversion tool
24.1.2. uconv - convert data from one encoding to another
24.2. 字符串处理命令expr
24.3. cat - concatenate files and print on the standard output
24.3.1. -s, --squeeze-blank suppress repeated empty output lines
24.3.2. -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
24.3.3. 与管道配合使用
24.4. nl - number lines of files
24.5. tr - translate or delete characters
24.5.1. 替换字符
24.5.2. 英文大小写转换
24.5.3. [CHAR*] 和 [CHAR*REPEAT]
24.5.4. -s, --squeeze-repeats replace each input sequence of a repeated character that is listed in SET1 with a single occurrence of that character
24.5.5. -d, --delete delete characters in SET1, do not translate
24.6. cut - remove sections from each line of files
24.6.1. 字符操作
24.6.2. 列操作
24.7. printf - format and print data
24.8. Free `recode' converts files between various character sets and surfaces.
24.9. /dev/urandom 随机字符串
24.10. col - filter reverse line feeds from input
24.11. apg - generates several random passwords
24.12. head/tail
24.12.1. 彩色输出
24.12.2. 跳过 n 行,输出后面内容
24.12.3. 尾部剪掉 n 行
24.13. 反转字符串或文件内容
24.14. TAB符号与空格处理
24.14.1. expand - convert tabs to spaces
24.14.2. unexpand - convert spaces to tabs
24.15. grep, egrep, fgrep, rgrep - print lines matching a pattern
24.15.1. 删除空行
24.15.2. -v, --invert-match
24.15.3. 输出控制(Output control)
24.15.4. Context control
24.15.5. Regexp selection and interpretation
24.15.6. fgrep
24.15.7. egrep
24.16. sort - sort lines of text files
24.16.1. 对列排序
24.16.2. -s, --stable stabilize sort by disabling last-resort comparison
24.17. uniq
24.18. awk
24.18.1. 处理列
24.18.2. printf
24.18.3. Pattern(字符匹配)
24.18.4. Built-in Variables (NR/NF)
24.18.5. Built-in Functions
24.18.6. 过滤相同的行
24.18.7. 数组演示
24.19. sed
24.19.1. 查找与替换
24.19.2. insert 插入字符
24.19.3. 追加字符
24.19.4. 修改字符
24.19.5. 删除字符
24.19.6. 行操作
24.19.7. 编辑文件
24.19.8. 正则表达式
24.19.9. 管道操作
24.19.10. 字母大小写转换
24.19.11. perl
24.19.12. 案例
24.20. ed, red - text editor
24.21. vim
24.21.1. vim 初始化
24.21.2. 查找与替换
24.21.3. 删除操作
24.21.4. 插入文件
24.21.5. 批处理
24.21.6. line()
24.21.7. set fileformat
24.21.8. 空格与TAB转换
24.22. XML 工具
24.22.1. xmllint - command line XML tool
24.22.2. xmlstarlet - command line XML/XSLT toolkit
24.23. jq - Command-line JSON processor
24.23.1. --raw-output
25. 表格操作/行列转换
25.1. column - columnate lists
25.2. paste - merge lines of files
25.3. join
26. standard input/output
26.1. standard input/output
26.1.1. xargs - build and execute command lines from standard input
26.2. flock - manage locks from shell scripts
27. 进制转换 - 16进制 - 8进制 - 二进制
27.1. od - dump files in octal and other formats
27.1.1. 16进制
27.1.2. 使用 od 随机生成密码
27.2. hexdump, hd -- ASCII, decimal, hexadecimal, octal dump
27.3. xxd - make a hexdump or do the reverse.
27.3.1. 指定每行的列数
27.3.2. 跳过字节
27.4. binutils
27.4.1. strings - print the strings of printable characters in files.
28. 文件比较
28.1. diff
28.2. sdiff
28.3. diff3
29. Wget - The non-interactive network downloader.
29.1. Logging and input file
29.1.1. -i, --input-file=FILE download URLs found in local or external FILE.
29.2. 下载相关参数
29.2.1. -O, --output-document=FILE write documents to FILE 保存到文件
29.3. HTTP options (HTTP 选项)
29.3.1. --post-data=STRING use the POST method; send STRING as the data.
29.3.2. header HTTP头定义
29.4. Recursive download
29.4.1. -r, --recursive specify recursive download.
29.4.2. -m, --mirror shortcut for -N -r -l inf --no-remove-listing.
29.5. --no-passive-ftp disable the "passive" transfer mode.
29.6. 下载一组连续的文件名
30. CURL - transfer a URL
30.1. 基本用法
30.2. 提交表单数据
30.3. 上传文件
30.4. connect-timeout
30.5. max-time
30.6. compressed
30.7. 代理服务器
30.8. -w, --write-out <format> 输出格式定义
30.9. -A/--user-agent <agent string>
30.10. referer
30.11. -v
30.12. -o, --output FILE Write output to <file> instead of stdout
30.13. -L, --location
30.14. -H/--header <line> Custom header to pass to server (H)
30.14.1. Last-Modified / If-Modified-Since
30.14.2. ETag / If-None-Match
30.14.3. Accept-Encoding:gzip,defalte
30.14.4. HOST
30.14.5. HTTP 认证
30.14.6. Accept
30.14.7. Content-Type
30.15. curl-config
30.16. 指定网络接口或者地址
30.17. Cookie 处理
30.18. Restful 应用 JSON 数据处理
30.18.1. Curl Oauth2
30.18.2. Curl + Oauth2 + Jwt
30.19. 访问自签名证书
30.20. HTTP2
30.21. FAQ
31. 信息摘要
31.1. cksum, sum -- display file checksums and block counts
31.2. md5sum - compute and check MD5 message digest
31.3.
32. envsubst - substitutes environment variables in shell format strings
32.1. envsubst - substitutes environment variables in shell format strings
32.2. parallel - build and execute shell command lines from standard input in parallel
32.3. multitail
32.4. Logging
32.4.1. logger - a shell command interface to the syslog(3) system log module
32.5. Password
32.5.1. Shadow password suite configuration.
32.5.2. newusers - update and create new users in batch
32.5.3. chpasswd - update passwords in batch mode
32.5.4. sshpass - noninteractive ssh password provider
33. 常用命令
33.1. 获取IP地址
33.2. 有趣的 Shell 应用
33.2.1. Ascii 星球大战电影
33.2.2. 天气预报
33.2.3. htop - interactive process viewer
33.2.4. elinks
33.2.5. chat

1. Shell