[root@localhost ~]# find /etc -name '*.conf' | egrep -o "[^/]*(\.conf)$"|tr 'a-z' 'A-Z' >/tmp/etc.conf [root@localhost ~]# cat /tmp/etc.conf RESOLV.CONF CA-LEGACY.CONF FASTESTMIRROR.CONF LANGPACKS.CONF SYSTEMD.CONF VERSION-GROUPS.CONF LVM.CONF LVMLOCAL.CONF ASOUND.CONF LDAP.CONF MLX4.CONF RDMA.CONF SMTPD.CONF
7.显示/var目录下一级子目录或文件的总数
[root@localhost ~]# ls /var | wc -l
8.取出/etc/group第三个字段数值最小的10个组的名字
[root@localhost ~]# sort -t: -k3 -n /etc/group|head -10 |cut -d':' -f1 root bin daemon sys adm tty disk lp mem kmem
9.将/etc/fstab和/etc/issue文件的内容合并为同一个内容后保存至/tmp/etc.test文件中
[root@localhost ~]# cat /etc/fstab /etc/issue > /tmp/etc.test [root@localhost ~]# cat /tmp/etc.test # # /etc/fstab # Created by anaconda on Sat May 13 10:12:58 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/cl-root / xfs defaults 0 0 UUID=2789d01a-4e2b-47a5-9c3c-537641648663 /boot xfs defaults 0 0 /dev/mapper/cl-swap swap swap defaults 0 0 \S Kernel \r on an \m
总结
以上所述是小编给大家介绍的Linux grep与正则表达式,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
您可能感兴趣的文章: