1.diff命令
diff是用来比较两个文加或目录的不同
diff westos westos1
读取过程中a表示添加,c表示更改,d表示删除,<表示第一个文件中的内容,>表示第二个文件中的内容,—分割线。
diff -b westos westos1 不检查空个字符的不同
diff -B westos westos1 不检查空白行的不同
diff -i westos westos1 不检查大小写的不同
diff -p westos westos1 文件为c语音时,显示差异所在函数名称。
diff -u westos westos1 > westos.path 生成补丁
diff -r test test1/ 比较子目录中的文件不同
2.patch命令
yum install patch -y 下载patch
patch westos westos.path 使用补丁使westos变为westos1
patch -b westos westos.path 生成文件时备份原文件westos.orig
3.cut命令
cut命令多用与字符截取
cut -d 指定分隔符
cut -f 1,4|1-4 指定截取的列
cut -c 1,4|1-4 指定截取的字符位置(1,4为1和4。1-4为1到4。)
cut -d : -f 1 pawwsd 显示第一个分隔符前的内容
cut -c 1,3 passwd 显示第一到第三字符位置的内容
4.sort命令
多用于字符排序
sort -n 纯数字排序
sort -r 倒序
sort -u 去掉重复数字
sort -o 输出到指定文件中
sort -t 指定分隔符
sort -k 指定要排序列
5.uniq命令
对重复字符做相应的处理
uniq -u 显示唯一的行
uniq -d 显示重复的行
uniq -c 列举出每个出现的次数,每行显示一个并统计次数。
6.&&和||
&&用来执行条件成立后执行的命令
||用来执行条件不成立后执行的命令
ping -c1 -w1 172.25.254.254 && echo yes || echo no ping254能通为yes,不通为no。
7.test命令
test命令和[]等同
rest"b"等同[“b”]
test “b” && echo yes || echo no a等于b,若正确显示yes,错误显示no。
[“b”] 不等于
[“b”] 等于
[“b”] 不等于
[“b”] 小于等于
[“b”] 小于
[“b”] 大于等于
[“b”] 大于
[“b” -a “b"] a不等于b,并且a大于b,同时成立。
[“b” -o “b"] a不等于b,或a大于b,成立一个即可。
[-z"c"] c是一个不是空的。
[“file1” -ef “file”] file1和file是一个文件。
[“file1” -nt “file”] file1比file新,先建立。
[“file1” -ot “file”] file1比file旧,后建立。
[-e “file”] 存不存在
[-f “file”] 为普通文件
[-L “file”] 为链接
[-S “file”] 套接字
[-d “file”] 为目录
[-c “file”] 字符设备
[-b “file”] 块设备
8.tr命令
echo hello | tr ‘a-z’ ‘A-Z’ 大小写转换