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. test 命令
19.3.1. 判断目录
19.4. I/O 重定向
19.4.1. stdout
19.4.2. error 重定向
19.4.3. 使用块记录日志
19.4.4. tee - read from standard input and write to standard output and files
19.4.5. 创建文件
19.4.6. 快速清空一个文件的内容
19.5. pipes (FIFOs)
19.6. mktemp - create a temporary file or directory 临时目录与文件
19.7. History 命令历史记录
19.7.1. .bash_history
19.7.2. 清理历史记录
19.7.3. .mysql_history
19.8. hash - hash database access method
19.9. prompt
19.10. 变量 variable
19.10.1. 系统变量
19.10.2. 表达式
19.10.3. Internal Environment Variables
19.10.4. set 设置变量
19.10.5. unset 变量销毁
19.10.6. 设置变量默认值
19.10.7. export 设置全局变量
19.10.8. declare
19.10.9. Numerical 数值运算
19.10.10. Strings 字符串操作
19.10.11. Array 数组
19.10.12. read 赋值多个变量
19.10.13. eval
19.10.14. typeset
19.10.15. envsubst - substitutes environment variables in shell format strings
19.11. conditions if and case
19.11.1. if
19.11.2. case
19.12. Loops for, while and until
19.12.1. for
19.12.2. while
19.12.3. until
19.13. Functions
19.13.1. Local variables
19.14. User interfaces
19.14.1. input
19.15. subshell
19.16. Example
19.16.1. 有趣的Shell
19.16.2. backup
19.16.3. CPU 核心数
19.16.4. Password
19.16.5. processes
19.16.6. Shell 技巧
19.16.7. to convert utf-8 from gb2312 code
19.16.8. 使用内存的百分比
19.16.9. 合并apache被cronlog分割的log文件
19.16.10. Linux 交集 差集 并集
20. Shell
20.1. Help Commands
20.1.1. man - an interface to the on-line reference manuals
20.2. getconf - Query system configuration variables
20.3. 快捷键
20.3.1. 命令行编辑命令
20.3.2. 重新执行命令快捷键
20.3.3. 终端控制快捷键
20.3.4. Bang (!) 命令
20.4. chsh - change login shell
20.5. 执行程序返回值
20.6. Z Shell
20.6.1. installing Z shell
20.6.2. Oh My ZSH!
20.6.3. Starting file
20.6.4. Prompting
20.6.5. Aliases
20.6.6. History
20.6.7. FAQ
20.7. Berkeley UNIX C shell (csh)
20.7.1.
20.8. KornShell
20.8.1.
20.9. fish shell
20.9.1. 安装 fish shell
20.9.2. 配置 fish
20.9.3. 环境变量
20.10. 有趣的 Shell 应用
20.10.1. Ascii 星球大战电影
20.10.2. 天气预报
20.10.3. htop - interactive process viewer
20.10.4. elinks
20.10.5. chat
21. 目录和文件
21.1. dirname
21.2. filename
21.2.1. 排除扩展名
21.2.2. 取扩展名
21.3. test - check file types and compare values
21.4. file — determine file type
21.5. stat
21.6. file – determine file type
21.7. mkdir - make directories
21.8. rename
21.9. touch
21.10. truncate
21.11. ls - list directory contents
21.11.1. full-time / time-style 定义日期时间格式
21.12. cp - copy files and directories
21.12.1. copy directories recursively
21.12.2. 覆盖已存在的文件
21.12.3. -a, --archive same as -dR --preserve=all
21.13. rm - remove files or directories
21.13.1. -bash: /bin/rm: Argument list too long
21.13.2. zsh: sure you want to delete all the files in /tmp [yn]?
21.14. df - report file system disk space usage
21.15. du - estimate file space usage
21.16. tac - concatenate and print files in reverse
21.17. split - split a file into pieces
21.17.1. 按行分割文件
21.17.2. 按尺寸分割文件
21.18. find - search for files in a directory hierarchy
21.18.1. 多目录匹配
21.18.2. name
21.18.3. regex
21.18.4. user
21.18.5. perm
21.18.6. type
21.18.7. -delete
21.18.8. exec
21.18.9. 排除目录
21.18.10. -mmin n File's data was last modified n minutes ago.
21.18.11. -ctime
21.18.12. -mtime / -mmin
21.18.13. --newer
21.18.14. -print / -printf
21.18.15. -size
21.18.16. -path
21.18.17. 目录深度控制
21.18.18. xargs
21.18.19. 查看空文件
22. 包管理 / 压缩 / 解压
22.1. tar — The GNU version of the tar archiving utility
22.1.1. tar examples
22.1.2. gunzip
22.1.3. b2zip
22.1.4. compress
22.1.5. .xz 文件
22.1.6. -t, --list
22.1.7. tar: Removing leading `/’ from member names
22.1.8. -C, --directory=DIR
22.1.9. --exclude
22.1.10. -T
22.1.11. 日期过滤
22.1.12. 保留权限
22.1.13. -r, --append
22.1.14. 远程传输
22.1.15. 分卷压缩
22.2. cpio - copy files to and from archives
22.3. gzip
22.4. zip, zipcloak, zipnote, zipsplit - package and compress (archive) files
22.5. bzip2, bunzip2 - a block-sorting file compressor
22.6. RAR
22.7. 7-Zip
22.7.1. 压缩
22.7.2. 浏览压缩包
22.7.3. 解压
22.7.4. Creates self extracting archive.
22.8. RAR
22.9. xz, unxz, xzcat, lzma, unlzma, lzcat - Compress or decompress .xz and .lzma files
23. 日期和时间
23.1. 日期格式
23.1.1. weekday name
23.2. -d --date=
23.2.1. 日期偏移量
23.2.2. 时间偏移
23.3. 时间戳
23.4. RFC 2822
23.5. UTC
23.6. 字符串转日期
24. 数值与运算
24.1. 数值运算
24.2. seq - print a sequence of numbers
24.3. bc - An arbitrary precision calculator language
25. 文本处理
25.1. iconv - Convert encoding of given files from one encoding to another
25.1.1. cconv - A iconv based simplified-traditional chinese conversion tool
25.1.2. uconv - convert data from one encoding to another
25.2. 字符串处理命令expr
25.3. cat - concatenate files and print on the standard output
25.3.1. -s, --squeeze-blank suppress repeated empty output lines
25.3.2. -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
25.3.3. 与管道配合使用
25.4. nl - number lines of files
25.5. tr - translate or delete characters
25.5.1. 替换字符
25.5.2. 英文大小写转换
25.5.3. [CHAR*] 和 [CHAR*REPEAT]
25.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
25.5.5. -d, --delete delete characters in SET1, do not translate
25.6. cut - remove sections from each line of files
25.6.1. 字符操作
25.6.2. 列操作
25.7. printf - format and print data
25.8. Free `recode' converts files between various character sets and surfaces.
25.9. /dev/urandom 随机字符串
25.10. col - filter reverse line feeds from input
25.11. apg - generates several random passwords
25.12. head/tail
25.12.1. 彩色输出
25.12.2. 跳过 n 行,输出后面内容
25.12.3. 尾部剪掉 n 行
25.13. 反转字符串或文件内容
25.14. TAB符号与空格处理
25.14.1. expand - convert tabs to spaces
25.14.2. unexpand - convert spaces to tabs
25.15. grep, egrep, fgrep, rgrep - print lines matching a pattern
25.15.1. 删除空行
25.15.2. -v, --invert-match
25.15.3. 输出控制(Output control)
25.15.4. Context control
25.15.5. Regexp selection and interpretation
25.15.6. fgrep
25.15.7. egrep
25.16. sort - sort lines of text files
25.16.1. 对列排序
25.16.2. -s, --stable stabilize sort by disabling last-resort comparison
25.17. uniq
25.18. awk
25.18.1. 处理列
25.18.2. printf
25.18.3. Pattern(字符匹配)
25.18.4. Built-in Variables (NR/NF)
25.18.5. Built-in Functions
25.18.6. 过滤相同的行
25.18.7. 数组演示
25.19. sed
25.19.1. 查找与替换
25.19.2. insert 插入字符
25.19.3. 追加字符
25.19.4. 修改字符
25.19.5. 删除字符
25.19.6. 行操作
25.19.7. 编辑文件
25.19.8. 正则表达式
25.19.9. 管道操作
25.19.10. 字母大小写转换
25.19.11. perl
25.19.12. 案例
25.20. ed, red - text editor
25.21. vim
25.21.1. vim 初始化
25.21.2. 查找与替换
25.21.3. 删除操作
25.21.4. 插入文件
25.21.5. 批处理
25.21.6. line()
25.21.7. set fileformat
25.21.8. 空格与TAB转换
25.22. XML 工具
25.22.1. xmllint - command line XML tool
25.22.2. xmlstarlet - command line XML/XSLT toolkit
25.23. jq - Command-line JSON processor
25.23.1. --raw-output
26. 表格操作/行列转换
26.1. column - columnate lists
26.2. paste - merge lines of files
26.3. join
27. standard input/output
27.1. standard input/output
27.1.1. xargs - build and execute command lines from standard input
27.2. flock - manage locks from shell scripts
28. 进制转换 - 16进制 - 8进制 - 二进制
28.1. od - dump files in octal and other formats
28.1.1. 16进制
28.1.2. 使用 od 随机生成密码
28.2. hexdump, hd -- ASCII, decimal, hexadecimal, octal dump
28.3. xxd - make a hexdump or do the reverse.
28.3.1. 指定每行的列数
28.3.2. 跳过字节
28.4. binutils
28.4.1. strings - print the strings of printable characters in files.
29. 文件比较
29.1. diff
29.2. sdiff
29.3. diff3
30. Wget - The non-interactive network downloader.
30.1. Logging and input file
30.1.1. -i, --input-file=FILE download URLs found in local or external FILE.
30.2. 下载相关参数
30.2.1. -O, --output-document=FILE write documents to FILE 保存到文件
30.3. HTTP options (HTTP 选项)
30.3.1. --post-data=STRING use the POST method; send STRING as the data.
30.3.2. header HTTP头定义
30.4. Recursive download
30.4.1. -r, --recursive specify recursive download.
30.4.2. -m, --mirror shortcut for -N -r -l inf --no-remove-listing.
30.5. --no-passive-ftp disable the "passive" transfer mode.
30.6. 下载一组连续的文件名
31. CURL - transfer a URL
31.1. 基本用法
31.2. 提交表单数据
31.3. 上传文件
31.4. connect-timeout
31.5. max-time
31.6. compressed
31.7. 代理服务器
31.8. -w, --write-out <format> 输出格式定义
31.9. -A/--user-agent <agent string>
31.10. referer
31.11. -v
31.12. -o, --output FILE Write output to <file> instead of stdout
31.13. -L, --location
31.14. -H/--header <line> Custom header to pass to server (H)
31.14.1. Last-Modified / If-Modified-Since
31.14.2. ETag / If-None-Match
31.14.3. Accept-Encoding:gzip,defalte
31.14.4. HOST
31.14.5. HTTP 认证
31.14.6. Accept
31.14.7. Content-Type
31.15. curl-config
31.16. 指定网络接口或者地址
31.17. Cookie 处理
31.18. Restful 应用 JSON 数据处理
31.18.1. Curl Oauth2
31.18.2. Curl + Oauth2 + Jwt
31.19. 访问自签名证书
31.20. HTTP2
31.21. FAQ
32. 信息摘要
32.1. cksum, sum -- display file checksums and block counts
32.2. md5sum - compute and check MD5 message digest
32.3.
33. envsubst - substitutes environment variables in shell format strings
33.1. envsubst - substitutes environment variables in shell format strings
33.2. parallel - build and execute shell command lines from standard input in parallel
33.3. multitail
33.4. Logging
33.4.1. logger - a shell command interface to the syslog(3) system log module
33.5. Password
33.5.1. Shadow password suite configuration.
33.5.2. newusers - update and create new users in batch
33.5.3. chpasswd - update passwords in batch mode
33.5.4. sshpass - noninteractive ssh password provider
34. 常用命令
34.1. 获取IP地址
34.2. 有趣的 Shell 应用
34.2.1. Ascii 星球大战电影
34.2.2. 天气预报
34.2.3. htop - interactive process viewer
34.2.4. elinks
34.2.5. chat