1.diff命令

diff是用来比较两个文加或目录的不同
diff westos westos1
读取过程中a表示添加,c表示更改,d表示删除,<表示第一个文件中的内容,>表示第二个文件中的内容,—分割线。
shall脚本常用的命令

diff -b westos westos1 不检查空个字符的不同
diff -B westos westos1 不检查空白行的不同
diff -i westos westos1 不检查大小写的不同
diff -p westos westos1 文件为c语音时,显示差异所在函数名称。
diff -u westos westos1 > westos.path 生成补丁
shall脚本常用的命令
diff -r test test1/ 比较子目录中的文件不同
shall脚本常用的命令

2.patch命令

yum install patch -y 下载patch
shall脚本常用的命令

patch westos westos.path 使用补丁使westos变为westos1
patch -b westos westos.path 生成文件时备份原文件westos.orig
shall脚本常用的命令

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 显示第一个分隔符前的内容
shall脚本常用的命令

cut -c 1,3 passwd 显示第一到第三字符位置的内容
shall脚本常用的命令

4.sort命令

多用于字符排序
sort -n 纯数字排序
shall脚本常用的命令

sort -r 倒序
shall脚本常用的命令

sort -u 去掉重复数字
shall脚本常用的命令

sort -o 输出到指定文件中
shall脚本常用的命令

sort -t 指定分隔符
sort -k 指定要排序列

5.uniq命令

对重复字符做相应的处理
uniq -u 显示唯一的行
shall脚本常用的命令

uniq -d 显示重复的行
shall脚本常用的命令

uniq -c 列举出每个出现的次数,每行显示一个并统计次数。
shall脚本常用的命令

6.&&和||

&&用来执行条件成立后执行的命令
||用来执行条件不成立后执行的命令
ping -c1 -w1 172.25.254.254 && echo yes || echo no ping254能通为yes,不通为no。
shall脚本常用的命令

7.test命令

test命令和[]等同
rest"a&quot;==&quot;a&quot;==&quot;b"等同[“a&quot;==&quot;a&quot;==&quot;b”]
test “a&quot;=&quot;a&quot; = &quot;b” && echo yes || echo no a等于b,若正确显示yes,错误显示no。
shall脚本常用的命令
[“a&quot;!=&quot;a&quot;!=&quot;b”] 不等于
[“a&quot;eq&quot;a&quot;-eq&quot;b”] 等于
[“a&quot;ne&quot;a&quot;-ne&quot;b”] 不等于
[“a&quot;le&quot;a&quot;-le&quot;b”] 小于等于
[“a&quot;lt&quot;a&quot;-lt&quot;b”] 小于
[“a&quot;ge&quot;a&quot;-ge&quot;b”] 大于等于
[“a&quot;gt&quot;a&quot;-gt&quot;b”] 大于
[“a&quot;ne&quot;a&quot;-ne&quot;b” -a “agt&quot;a”-gt&quot;b"] a不等于b,并且a大于b,同时成立。
[“a&quot;ne&quot;a&quot;-ne&quot;b” -o “agt&quot;a”-gt&quot;b"] a不等于b,或a大于b,成立一个即可。
[-z"c&quot;]c[n&quot;c&quot;] c为一个空的。 [-n&quot;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’ 大小写转换
shall脚本常用的命令

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-05-11
  • 2021-12-10
  • 2021-07-31
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-10
  • 2021-10-21
  • 2021-12-10
  • 2021-12-10
  • 2021-12-10
  • 2021-09-01
相关资源
相似解决方案