常用命令

来自Shiyin's note
Shen讨论 | 贡献2013年4月18日 (四) 06:33的版本
跳到导航 跳到搜索

umask

umask是对权限的过滤器,因此它的工作方式和chmod恰好相反。全部权限等价与777(rwxrwxrwx),umask值0222(-w--w--w-)则代表权限555(r-xr-xr-x)


cat

  • cat file1 file2 | sort | uniq
取出两个文件的并集(重复的行只保留一份)
  • cat file1 file2 | sort | uniq -d
取出两个文件的交集(只留下同时存在于两个文件中的文件)
  • cat file1 file2 | sort | uniq -u
删除交集,留下其他的行
  • cat file1 file2 > file3
paste file2 to the end of file1 and write to file3

tr

  • tr -d ' ' < test.txt >> test2.txt
删除 test.txt 中间所有的空格,输出至test2.txt


  • tr ' ' ‘ *’ < test.txt >> test2.txt
替换 test.txt 中间所有的空格为*,输出至test2.txt
Note: 输出必须重定向,可能效果没有sed好

专题

dd

find

awk

sed