日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

云計(jì)算學(xué)習(xí)路線課程大綱資料:進(jìn)程管道 Piping

 千鋒云計(jì)算 2019-08-21

今天給大家分享一些云計(jì)算學(xué)習(xí)路線課程大綱資料,這篇文章是關(guān)于進(jìn)程管道 Piping的一些學(xué)習(xí)筆記資料,希望能給大家一些幫助:

====================================================================================

· Use redirection characters to control output to files. 重定向是用來輸出到一個(gè)文件當(dāng)中去

· Use piping to control output to other programs. 管道也是進(jìn)程控制輸出到一個(gè)程序

files: > 2> file1.txt /dev/pts/2 /dev/tty1 /dev/null /dev/sda

programs: |

進(jìn)程管道

用法:command1 | command2 |command3 |...

[root@tianyun ~]# ll /dev/ |less

[root@tianyun ~]# ps aux |grep 'sshd'

[root@tianyun ~]# rpm -qa |grep 'httpd' //查詢所有安裝的軟件包,過濾包含httpd的包

[root@tianyun ~]# yum list |grep 'httpd'

案例1:將/etc/passwd中的用戶按UID大小排序

[root@tianyun ~]# //以: 分隔,將第三列按字?jǐn)?shù)升序

[root@tianyun ~]# sort -t":" -k3 -n /etc/passwd -r //逆序

[root@tianyun ~]# sort -t":" -k3 -n /etc/passwd |head

-t 指定字段分隔符--field-separator

-k 指定列

-n 按數(shù)值

案例2:統(tǒng)計(jì)出最占CPU的5個(gè)進(jìn)程0

[root@tianyun ~]# ps aux --sort=-%cpu |head -6

案例3:統(tǒng)計(jì)當(dāng)前/etc/passwd中用戶使用的shell類型

思路:取出第七列(shell) | 排序(把相同歸類)| 去重

[root@tianyun ~]# awk -F: '{print $7}' /etc/passwd

[root@tianyun ~]# awk -F: '{print $7}' /etc/passwd |sort

[root@tianyun ~]# awk -F: '{print $7}' /etc/passwd |sort |uniq

[root@tianyun ~]# awk -F: '{print $7}' /etc/passwd |sort |uniq -c

131 /bin/bash

1 /bin/sync

1 /sbin/halt

63 /sbin/nologin

1 /sbin/shutdown

-F: 指定字段分隔符

$7 第七個(gè)字段

案例4: 統(tǒng)計(jì)網(wǎng)站的訪問情況 top 20

思路: 打印所有訪問的連接 | 過濾訪問網(wǎng)站的連接 | 打印用戶的IP | 排序 | 去重

[root@tianyun ~]# yum -y install httpd

[root@tianyun ~]# systemctl start httpd

[root@tianyun ~]# systemctl stop firewalld

[root@tianyun ~]# ss -an |grep :80 |awk -F":" '{print $8}' |sort |uniq -c

4334 192.168.0.66

1338 192.168.10.11

1482 192.168.10.125

44 192.168.10.183

3035 192.168.10.213

375 192.168.10.35

362 192.168.10.39

[root@tianyun ~]# ss -an |grep :80 |awk -F":" '{print $8}' |sort |uniq -c |sort -k1 -rn |head -n 20

案例5: 打印當(dāng)前所有IP

[root@tianyun ~]# ip addr |grep 'inet ' |awk '{print $2}' |awk -F"/" '{print $1}'

127.0.0.1

192.168.2.115

案例6:打印根分區(qū)已用空間的百分比(僅打印數(shù)字)

[root@tianyun ~]# df -P |grep '/$' |awk '{print $5}' |awk -F"%" '{print $1}'

tee管道

[root@tianyun ~]# ip addr |grep 'inet ' |tee ip.txt |awk -F"/" '{print $1}' |awk '{print $2}'

127.0.0.1

172.16.60.1

[root@tianyun ~]# cat ip.txt

inet 127.0.0.1/8 scope host lo

inet 172.16.60.1/24 brd 172.16.60.255 scope global eth0

[root@tianyun ~]# ip addr |grep 'inet ' |tee -a ip.txt |awk -F"/" '{print $1}' |awk '{print $2}'

127.0.0.1

172.16.60.1

[root@tianyun ~]# date >date.txt

[root@tianyun ~]# date |tee date.txt

[root@tianyun ~]# top -d 1 -b -n 1 > top.txt

[root@tianyun ~]# top -d 1 -b -n 1 |tee top.txt

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多