本文共 2290 字,大约阅读时间需要 7 分钟。
0130
sed 命令 常用选项 -n:模式空间中的内容不输出到屏幕 sed -n ‘s#abcd#AAAA#p’ /tmp/123.txt 将123.txt文本中所有的abcd替换为AAAA -r:支持使用正则表达式 -i:编辑原文件 -e:多点编辑 示例:删除#号和UUID开头的行sed -e '/^UUID/d' -e '/^#\+/d' /etc/fstab 编辑命令 d:删除 sed '/^UUID/d' /etc/fstab p:显示模式空间中的内容 a \text:在行后追加文本“text” i \text:在行前追加文件“text” c \text:把匹配到的内容替换为“text” !:取反 示例:删除所有除了#号开头的行 sed '/^#/!d' /etc/fstab s///:查找替换(///可以用###或者@@@代替) g:全局替换 sed 's#abcd#AAAA#g' /tmp/123.txt 将123.txt文本中所有的abcd替换为AAAA p:显示替换成功的行
20190211-----------------------------------------------------------------------------------------------------------
rmdir – remove empty directories, 删除空目录,非空则无法删除语法:rmdir [OPTION]… DIRECTORY…
常用选项:
选项 | 含义
—— | —— -p | 递归删除,当删除完基名目录时,如果其父目录也为空,则一并删除;依此类推,直到非空目录为止 -v | 显示命令执行的详细结果,通常与-p一同使用 示例:rmdir -pv /tmp/a/b/c
递归删除/tmp/a/b/c,直到非空目录为止,并显示删除详细结果20190221-----------------------------------------------------------------------------------------------------------
当前目录下按照文件大小排序[root@test23 script]# ls -lSh
总用量 44K -rw-r—r— 1 root root 2.4K 12月 8 17:24 test.conf -rw-r—r— 1 root root 1.3K 11月 30 16:05 count_pig.sh -rw-r—r— 1 root root 1.3K 12月 21 20:31 count_pig.sh.bak -rw-r—r— 1 root root 1.2K 1月 24 15:18 get_holiday.sh -rw-r—r— 1 root root 853 12月 6 12:23 two_points.sh -rw-r—r— 1 root root 817 1月 24 14:55 holiday.txt -rw-r—r— 1 root root 458 1月 25 19:52 create_passwd.sh -rw-r—r— 1 root root 134 12月 18 16:44 -rw-r—r— 1 root root 119 12月 18 16:56 -rw-r—r— 1 root root 96 12月 8 15:02 test.php -rw-r—r— 1 root root 38 12月 1 10:44 -rw-r—r— 1 root root 0 1月 24 00:00 tempfilels
[root@test23 script]# ls -Sh test.conf count_pig.sh.bak two_points.sh create_passwd.sh count_pig.sh get_holiday.sh holiday.txt test.php tempfilefind
[root@test23 script]# find ./ -type f -printf ‘%s %p\n’ | sort -rn 2443 ./test.conf 1318 ./count_pig.sh.bak 1318 ./count_pig.sh 1180 ./get_holiday.sh 853 ./two_points.sh 817 ./holiday.txt 458 ./create_passwd.sh 134 ./all.sh 119 ./99.sh 96 ./test.php 38 ./test.sh 0 ./tempfiledu
[root@test23 script]# du -b * | sort -nr 2443 test.conf 1318 count_pig.sh.bak 1318 count_pig.sh 1180 get_holiday.sh 853 two_points.sh 817 holiday.txt 458 create_passwd.sh 134 119 96 test.php 38 0 tempfile转载地址:http://fgzgn.baihongyu.com/