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

部分 III. Shell

目录

22. Bash Shell
22.1. bash - GNU Bourne-Again SHell
22.1.1. -n 检查脚本是否有语法错误
22.1.2. -x 显示详细运行过程
22.2. 切换身份
22.3. I/O 重定向
22.3.1. stdout
22.3.2. error 重定向
22.3.3. 使用块记录日志
22.3.4. test - 条件判断命令
22.3.5. tee - read from standard input and write to standard output and files
22.3.6. 创建文件
22.3.7. 快速清空一个文件的内容
22.4. pipes (FIFOs)
22.5. mktemp - create a temporary file or directory 临时目录与文件
22.6. History 命令历史记录
22.6.1. .bash_history
22.6.2. 清理历史记录
22.6.3. .mysql_history
22.7. hash - hash database access method
22.8. prompt
22.9. 变量 variable
22.9.1. 系统变量
22.9.2. 表达式
22.9.3. Internal Environment Variables
22.9.4. set 设置变量
22.9.5. unset 变量销毁
22.9.6. 设置变量默认值
22.9.7. export 设置全局变量
22.9.8. declare
22.9.9. Numerical 数值运算
22.9.10. Strings 字符串操作
22.9.11. Array 数组
22.9.12. read 赋值多个变量
22.9.13. eval
22.9.14. typeset
22.9.15. envsubst - substitutes environment variables in shell format strings
22.10. conditions if and case
22.10.1. if
22.10.2. case
22.11. Loops for, while and until
22.11.1. for
22.11.2. while
22.11.3. until
22.12. Functions
22.12.1. Local variables
22.13. User interfaces
22.13.1. input
22.14. subshell
22.15. Help Commands
22.15.1. man - an interface to the on-line reference manuals
22.16. getconf - Query system configuration variables
22.17. 快捷键
22.17.1. 命令行编辑命令
22.17.2. 重新执行命令快捷键
22.17.3. 终端控制快捷键
22.17.4. Bang (!) 命令
22.18. chsh - change login shell
22.19. 执行程序返回值
22.20. Z Shell
22.20.1. installing Z shell
22.20.2. Oh My ZSH!
22.20.3. Starting file
22.20.4. Prompting
22.20.5. Aliases
22.20.6. History
22.20.7. FAQ
22.21. Berkeley UNIX C shell (csh)
22.21.1.
22.22. KornShell
22.22.1.
22.23. fish shell
22.23.1. 安装 fish shell
22.23.2. 配置 fish
22.23.3. 环境变量
22.24. 有趣的 Shell 应用
22.24.1. Ascii 星球大战电影
22.24.2. 天气预报
22.24.3. htop - interactive process viewer
22.24.4. elinks
22.24.5. chat
22.25. Example
22.25.1. 有趣的Shell
22.25.2. backup
22.25.3. CPU 核心数
22.25.4. Password
22.25.5. processes
22.25.6. Shell 技巧
22.25.7. to convert utf-8 from gb2312 code
22.25.8. 使用内存的百分比
22.25.9. 合并apache被cronlog分割的log文件
22.25.10. Linux 交集 差集 并集
23. 目录和文件
23.1. dirname - 提取目录部分
23.2. basename - 提取文件名部分
23.2.1. 排除扩展名
23.2.2. 取扩展名
23.3. file — determine file type
23.4. stat
23.5. file – determine file type
23.6. mkdir - make directories
23.7. rename
23.8. touch
23.9. truncate
23.10. ls - list directory contents
23.10.1. full-time / time-style 定义日期时间格式
23.11. cp - copy files and directories
23.11.1. copy directories recursively
23.11.2. 覆盖已存在的文件
23.11.3. -a, --archive same as -dR --preserve=all
23.12. rm - remove files or directories
23.12.1. -bash: /bin/rm: Argument list too long
23.12.2. zsh: sure you want to delete all the files in /tmp [yn]?
23.13. df - report file system disk space usage
23.14. du - estimate file space usage
23.15. tac - concatenate and print files in reverse
23.16. split - split a file into pieces
23.16.1. 按行分割文件
23.16.2. 按尺寸分割文件
23.17. find - search for files in a directory hierarchy
23.17.1. 多目录匹配
23.17.2. name
23.17.3. regex
23.17.4. user
23.17.5. perm
23.17.6. type
23.17.7. -delete
23.17.8. exec
23.17.9. 排除目录
23.17.10. -ctime / -cmin - 按状态改变时间查找
23.17.11. -mtime / -mmin - 按修改时间查找
23.17.12. --newer
23.17.13. -print / -printf
23.17.14. -size
23.17.15. -path
23.17.16. 目录深度控制
23.17.17. xargs
23.17.18. 查看空文件
24. 包管理 / 压缩 / 解压
24.1. tar — The GNU version of the tar archiving utility
24.1.1. tar examples
24.1.2. gunzip
24.1.3. b2zip
24.1.4. compress
24.1.5. .xz 文件
24.1.6. -t, --list
24.1.7. tar: Removing leading `/’ from member names
24.1.8. -C, --directory=DIR
24.1.9. --exclude
24.1.10. -T
24.1.11. 日期过滤
24.1.12. 保留权限
24.1.13. -r, --append
24.1.14. 远程传输
24.1.15. 分卷压缩
24.2. cpio - copy files to and from archives
24.3. gzip
24.4. zip, zipcloak, zipnote, zipsplit - package and compress (archive) files
24.5. bzip2, bunzip2 - a block-sorting file compressor
24.6. RAR
24.7. 7-Zip
24.7.1. 压缩
24.7.2. 浏览压缩包
24.7.3. 解压
24.7.4. Creates self extracting archive.
24.8. RAR
24.9. xz, unxz, xzcat, lzma, unlzma, lzcat - Compress or decompress .xz and .lzma files
25. 日期和时间
25.1. 日期格式
25.1.1. weekday name
25.2. -d --date=
25.2.1. 日期偏移量
25.2.2. 时间偏移
25.3. 时间戳
25.4. RFC 2822
25.5. UTC
25.6. 字符串转日期
26. 数值与运算
26.1. 数值运算
26.2. seq - print a sequence of numbers
26.3. bc - An arbitrary precision calculator language
27. 文本处理
27.1. iconv - Convert encoding of given files from one encoding to another
27.1.1. cconv - A iconv based simplified-traditional chinese conversion tool
27.1.2. uconv - convert data from one encoding to another
27.2. 字符串处理命令expr
27.3. cat - concatenate files and print on the standard output
27.3.1. -s, --squeeze-blank suppress repeated empty output lines
27.3.2. -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
27.3.3. 与管道配合使用
27.4. nl - number lines of files
27.5. tr - translate or delete characters
27.5.1. 替换字符
27.5.2. 英文大小写转换
27.5.3. [CHAR*] 和 [CHAR*REPEAT]
27.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
27.5.5. -d, --delete delete characters in SET1, do not translate
27.6. cut - remove sections from each line of files
27.6.1. 字符操作
27.6.2. 列操作
27.7. printf - format and print data
27.8. Free `recode' converts files between various character sets and surfaces.
27.9. /dev/urandom 随机字符串
27.10. col - filter reverse line feeds from input
27.11. apg - generates several random passwords
27.12. head/tail
27.12.1. 彩色输出
27.12.2. 跳过 n 行,输出后面内容
27.12.3. 尾部剪掉 n 行
27.13. 反转字符串或文件内容
27.14. TAB符号与空格处理
27.14.1. expand - convert tabs to spaces
27.14.2. unexpand - convert spaces to tabs
27.15. grep, egrep, fgrep, rgrep - print lines matching a pattern
27.15.1. 删除空行
27.15.2. -v, --invert-match
27.15.3. 输出控制(Output control)
27.15.4. Context control
27.15.5. Regexp selection and interpretation
27.15.6. fgrep
27.15.7. egrep
27.16. sort - sort lines of text files
27.16.1. 对列排序
27.16.2. -s, --stable stabilize sort by disabling last-resort comparison
27.17. uniq
27.18. awk
27.18.1. 处理列
27.18.2. printf
27.18.3. Pattern(字符匹配)
27.18.4. Built-in Variables (NR/NF)
27.18.5. Built-in Functions
27.18.6. 过滤相同的行
27.18.7. 数组演示
27.19. sed
27.19.1. 查找与替换
27.19.2. insert 插入字符
27.19.3. 追加字符
27.19.4. 修改字符
27.19.5. 删除字符
27.19.6. 行操作
27.19.7. 编辑文件
27.19.8. 正则表达式
27.19.9. 管道操作
27.19.10. 字母大小写转换
27.19.11. perl
27.19.12. 案例
27.20. ed, red - text editor
27.21. vim
27.21.1. vim 初始化
27.21.2. 查找与替换
27.21.3. 删除操作
27.21.4. 插入文件
27.21.5. 批处理
27.21.6. line()
27.21.7. set fileformat
27.21.8. 空格与TAB转换
27.22. XML 工具
27.22.1. xmllint - command line XML tool
27.22.2. xmlstarlet - command line XML/XSLT toolkit
27.23. jq - Command-line JSON processor
27.23.1. --raw-output
28. 表格操作/行列转换
28.1. column - columnate lists
28.2. paste - merge lines of files
28.3. join
29. standard input/output
29.1. standard input/output
29.1.1. xargs - build and execute command lines from standard input
29.2. flock - manage locks from shell scripts
30. 进制转换 - 16进制 - 8进制 - 二进制
30.1. od - dump files in octal and other formats
30.1.1. 16进制
30.1.2. 使用 od 随机生成密码
30.2. hexdump, hd -- ASCII, decimal, hexadecimal, octal dump
30.3. xxd - make a hexdump or do the reverse.
30.3.1. 指定每行的列数
30.3.2. 跳过字节
30.4. binutils
30.4.1. strings - print the strings of printable characters in files.
31. 文件比较
31.1. diff
31.2. sdiff
31.3. diff3
32. Wget - The non-interactive network downloader.
32.1. Logging and input file
32.1.1. -i, --input-file=FILE download URLs found in local or external FILE.
32.2. 下载相关参数
32.2.1. -O, --output-document=FILE write documents to FILE 保存到文件
32.3. HTTP options (HTTP 选项)
32.3.1. --post-data=STRING use the POST method; send STRING as the data.
32.3.2. header HTTP头定义
32.4. Recursive download
32.4.1. -r, --recursive specify recursive download.
32.4.2. -m, --mirror shortcut for -N -r -l inf --no-remove-listing.
32.5. --no-passive-ftp disable the "passive" transfer mode.
32.6. 下载一组连续的文件名
33. CURL - transfer a URL
33.1. 基本用法
33.2. 提交表单数据
33.3. 上传文件
33.4. connect-timeout
33.5. max-time
33.6. compressed
33.7. 代理服务器
33.8. -w, --write-out <format> 输出格式定义
33.9. -A/--user-agent <agent string>
33.10. referer
33.11. -v
33.12. -o, --output FILE Write output to <file> instead of stdout
33.13. -L, --location
33.14. -H/--header <line> Custom header to pass to server (H)
33.14.1. Last-Modified / If-Modified-Since
33.14.2. ETag / If-None-Match
33.14.3. Accept-Encoding:gzip,defalte
33.14.4. HOST
33.14.5. HTTP 认证
33.14.6. Accept
33.14.7. Content-Type
33.15. curl-config
33.16. 指定网络接口或者地址
33.17. Cookie 处理
33.18. Restful 应用 JSON 数据处理
33.18.1. Curl Oauth2
33.18.2. Curl + Oauth2 + Jwt
33.19. 访问自签名证书
33.20. HTTP2
33.21. FAQ
34. 信息摘要
34.1. cksum, sum -- display file checksums and block counts
34.2. md5sum - compute and check MD5 message digest
34.3.
35. envsubst - substitutes environment variables in shell format strings
35.1. envsubst - substitutes environment variables in shell format strings
35.2. parallel - build and execute shell command lines from standard input in parallel
35.3. multitail
35.4. Logging
35.4.1. logger - a shell command interface to the syslog(3) system log module
35.5. Password
35.5.1. Shadow password suite configuration.
35.5.2. newusers - update and create new users in batch
35.5.3. chpasswd - update passwords in batch mode
35.5.4. sshpass - noninteractive ssh password provider
36. 常用命令
36.1. 获取IP地址
36.2. 有趣的 Shell 应用
36.2.1. Ascii 星球大战电影
36.2.2. 天气预报
36.2.3. htop - interactive process viewer
36.2.4. elinks
36.2.5. chat

1. Shell