$ cat /etc/fstab > ./s
$ ls
readme.txt s test.bed
$ cat s
/dev/vda1 / ext3 noatime,acl,user_xattr 1 1
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
/dev/vdb1 /public ext3 defaults 0 0
/dev/vdc /home ext3 defaults 0 0
#/dev/vdf /trainee ext3 defaults 0 0
/mnt/10GiB.swap swap swap defaults 0 0
>:覆盖输出
>>:追加输出
$ cat /etc/passwd >> ./s
$ cat s
/dev/vda1 / ext3 noatime,acl,user_xattr 1 1
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
/dev/vdb1 /public ext3 defaults 0 0
/dev/vdc /home ext3 defaults 0 0
#/dev/vdf /trainee ext3 defaults 0 0
/mnt/10GiB.swap swap swap defaults 0 0
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
管道
前一个命令输出,作为后一个命令的输入
命令1 | 命令2 | 命令3
$ cut -d: -f1 /etc/passwd | sort -n | tr 'a-z' 'A-Z'
AMLIANG
_APT
BACKUP
BIN
DAEMON
DBJIANG
DNSMASQ
DWANG
DZHANG
$ cut -d: -f7 /etc/passwd | sort -u
/bin/bash
/bin/false
/bin/sync
/usr/sbin/nologin
$ head -4 readme.txt #取最后一行
Welcome to Biotrainee() !
This is your personal account in our Cloud.
Have a fun with it.
Please feel free to contact with me( email to jmzeng1314@163.com )
$ head -4 readme.txt | tail -1
Please feel free to contact with me( email to jmzeng1314@163.com )
$ tail -9 /etc/passwd | head -1 | cut -d: -f1,7 | tee ./s #保存并显示 tee
s7:
$ ls
readme.txt s
$ cat s
s7:
$ ls -d /etc/pa* | wc -l
5
网友评论