1 列出/etc/下以。conf结尾的文件
[redsun@jiange root]$ ls /etc/*.conf | tr 'a-z' 'A-Z' | sed 's/ETC/etc/' > /tmp/etc.conf
[redsun@jiange root]$ more /tmp/etc.
etc.conf etc.test
[redsun@jiange root]$ more /tmp/etc.conf
/etc/ASOUND.CONF
/etc/DNSMASQ.CONF
/etc/DRACUT.CONF
/etc/E2FSCK.CONF
/etc/HOST.CONF
/etc/KDUMP.CONF
/etc/KRB5.CONF
/etc/LD.SO.CONF
/etc/LIBAUDIT.CONF
/etc/LIBUSER.CONF
/etc/LOCALE.CONF
/etc/LOGROTATE.CONF
/etc/MAN_DB.CONF
/etc/MKE2FS.CONF
/etc/NSSWITCH.CONF
/etc/RESOLV.CONF
/etc/RSYSLOG.CONF
/etc/SESTATUS.CONF
/etc/SUDO.CONF
/etc/SUDO-LDAP.CONF
/etc/SYSCTL.CONF
/etc/TCSD.CONF
/etc/VCONSOLE.CONF
/etc/YUM.CONF
2.取出/var目录下一级子目录或文件的总个数
[redsun@jiange root]$ ls /var/
adm crash empty gopher lib lock mail opt run tmp
cache db games kerberos local log nis preserve spool yp
[redsun@jiange root]$ ls /var/ | wc -l
20
3.取出/etc/group文件中第三个字段数值最小的10个组的名字
[redsun@jiange root]$ more /etc/group | sort -t: -k3 -n | sed -n '1, +10p' | cut -d : -f 1
root
bin
daemon
sys
adm
tty
disk
lp
mem
kmem
wheel
4. 重定向
[redsun@jiange root]$ more /etc/fstab /etc/issue >> /tmp/etc.test
[redsun@jiange root]$ more /tmp/etc.test
/etc/fstab /etc/issue
::::::::::::::
/etc/fstab
::::::::::::::
#
# /etc/fstab
# Created by anaconda on Sun Nov 13 21:59:15 2016
#
# 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/centos-root / xfs defaults 0 0
UUID=deeaf891-c904-4d2b-95f6-c56afecdd40e /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
::::::::::::::
/etc/issue
::::::::::::::
\S
Kernel \r on an \m
原创文章,作者:N24_xingxiu,如若转载,请注明出处:http://www.178linux.com/59144