天天看点

linux管道符的依赖,Linux中的管道符

一 多命令顺序执行

linux管道符的依赖,Linux中的管道符

二 实战

[[email protected] local]# date;ls;cd /etc;pwd

Sat Jul 15 16:42:39 CST 2017

access.log cs.log etc go jdk1.8.0_111 lib libexec share test2.log test.log

bin error.log games include jdk-8u111-linux-x64.tar.gz lib64 sbin src test3.log

/etc

[[email protected] etc]# date;find /tmp/abc;date

Sat Jul 15 16:48:01 CST 2017

/tmp/abc

Sat Jul 15 16:48:01 CST 2017

[[email protected] etc]# cd ~

[[email protected] ~]# ls && echo yes

anaconda-ks.cfg Documents gobin goproject japan Pictures test

ChangeLog-2.6.0 Downloads goc2p hello.shell linux-2.6.39.tar.bz2 Public Videos

Desktop go1.8.3.linux-amd64.tar.gz golib initial-setup-ks.cfg Music Templates

yes

[[email protected] ~]# lsfdf && echo yes

bash: lsfdf: command not found...

[email protected] ~]# lsfdf || echo yes

bash: lsfdf: command not found...

yes

[[email protected] ~]# ls || echo yes

anaconda-ks.cfg Documents gobin goproject japan Pictures test

ChangeLog-2.6.0 Downloads goc2p hello.shell linux-2.6.39.tar.bz2 Public Videos

Desktop go1.8.3.linux-amd64.tar.gz golib initial-setup-ks.cfg Music Templates

[[email protected] ~]# ls && echo yes || echo no

anaconda-ks.cfg Documents gobin goproject japan Pictures test

ChangeLog-2.6.0 Downloads goc2p hello.shell linux-2.6.39.tar.bz2 Public Videos

Desktop go1.8.3.linux-amd64.tar.gz golib initial-setup-ks.cfg Music Templates

yes

[[email protected] ~]# lsre && echo yes || echo no

bash: lsre: command not found...

no

三 管道符

命令格式:

命令1|命令2

命令1的正确输出作为命令2的操作对象

四 实战

[[email protected] ~]# ls -l|more

total 89304

-rw-------. 1 root root 1579 Oct 26 2016 anaconda-ks.cfg

-rw-r--r--. 1 root root 12777 Dec 18 2003 ChangeLog-2.6.0

drwxr-xr-x. 2 root root 6 Oct 28 2016 Desktop

drwxr-xr-x. 2 root root 6 Oct 28 2016 Documents

drwxr-xr-x. 2 root root 6 Oct 28 2016 Downloads

-rw-r--r--. 1 root root 90029041 Jul 8 15:13 go1.8.3.linux-amd64.tar.gz

drwxr-xr-x. 2 root root 15 Jul 8 19:26 gobin

drwxr-xr-x. 6 root root 4096 Jul 8 18:11 goc2p

drwxr-xr-x. 4 root root 26 Jul 8 19:46 golib

drwxr-xr-x. 2 root root 6 Jul 8 18:10 goproject

-rwxr-xr-x. 1 root root 79 Jul 15 14:39 hello.shell

-rw-------. 1 root root 1627 Oct 26 2016 initial-setup-ks.cfg

drwxr-xr-x. 4 root root 29 Jul 11 21:16 japan

-rw-r--r--. 1 root root 1383989 Nov 12 2016 linux-2.6.39.tar.bz2

drwxr-xr-x. 2 root root 6 Oct 28 2016 Music

drwxr-xr-x. 2 root root 6 Oct 28 2016 Pictures

drwxr-xr-x. 2 root root 6 Oct 28 2016 Public

drwxr-xr-x. 2 root root 6 Oct 28 2016 Templates

drwxr-xr-x. 3 root root 57 Jul 15 09:18 test

drwxr-xr-x. 2 root root 6 Oct 28 2016 Videos

[[email protected] ~]# netstat -an | grep ESTABLISHED

tcp 0 0 192.168.0.106:22 192.168.0.101:35342 ESTABLISHED

[[email protected] ~]# netstat -an | grep ESTABLISHED |wc -l

1