SCRIPTING AND SHELL 脚本和Shell
Shell basics Shell 基础知识
Command editing 命令编辑
- vi
- emacs
Pipes and redirection 管道和重定向
1 | $ echo "This is a test message." > /tmp/mymessage |
Variables and quoting 变量和引用
1 | $ ectdir='/etc' |
Common filter commands 常见的过滤命令
cut
separate lines into fields
sort
sort lines 排序行
| Opt | Meaning | Chinese |
|---|---|---|
| -b | Ignore leading whitespace | 忽略前导空白 |
| -f | Case insensitive sorting | 不分大小写排序 |
| -k | Specify the columns that form the sort key | 指定组成排序键的列 |
| -n | Compare fields as integer numbers | 将字段作为整数进行比较 |
| -r | Reverse sort order | 反向排序顺序 |
| -t | Set field separator(the default is whitespace) | 设置字段分隔符(默认为空格) |
| -u | Output unique records only | 只输出独特的记录 |
uniq
print unique lines
wc
count lines, words, and characters
tee
copy input to two places
grep
search text