博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux 小技巧
阅读量:3923 次
发布时间:2019-05-23

本文共 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 tempfile

  1. ls

    [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 tempfile

  2. find

    [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 ./tempfile

  3. du

    [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/

你可能感兴趣的文章
蓝牙核心规范中HCI层的研究与开发分析□ 张 熠 姜玉泉 《电脑知识与技术》 2007年第09期
查看>>
蓝牙协议的命令和事件
查看>>
基于蓝牙的数据传输系统的设计
查看>>
开发 Linux 后台服务进程
查看>>
Linux操作系统下如何生成软件依赖关系图
查看>>
程序员,如何选择合适的程序语言
查看>>
linux下syslog使用说明
查看>>
ar和nm命令的使用
查看>>
__func__标识符
查看>>
define小结
查看>>
C99标准更新
查看>>
c语言中的内存对齐
查看>>
BlueZ HID不安全设备连接漏洞
查看>>
指针变量的运算
查看>>
蓝牙模块在HHARM2410上的移植
查看>>
linux环境变量文件
查看>>
守护进程
查看>>
glib 中 IO Channels 理解
查看>>
[linux]警告:检测到时钟错误。您的创建可能是不完整的。
查看>>
动态库的Makefile.am编写
查看>>