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

一 多命令顺序执行

0818b9ca8b590ca3270a3433284dd417.png

二 实战

[root@localhost 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

[root@localhost etc]# date;find /tmp/abc;date

Sat Jul 15 16:48:01 CST 2017

/tmp/abc

Sat Jul 15 16:48:01 CST 2017

[root@localhost etc]# cd ~

[root@localhost ~]# 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

[root@localhost ~]# lsfdf && echo yes

bash: lsfdf: command not found...

root@localhost ~]# lsfdf || echo yes

bash: lsfdf: command not found...

yes

[root@localhost ~]# 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

[root@localhost ~]# 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

[root@localhost ~]# lsre && echo yes || echo no

bash: lsre: command not found...

no

三 管道符

命令格式:

命令1|命令2

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

四 实战

[root@localhost ~]# 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

[root@localhost ~]# netstat -an | grep ESTABLISHED

tcp 0 0 192.168.0.106:22 192.168.0.101:35342 ESTABLISHED

[root@localhost ~]# netstat -an | grep ESTABLISHED |wc -l

1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值