七、文本處理工具-PPT做業題

1、做業:

七、文本處理工具-PPT做業題
七、文本處理工具-PPT做業題
七、文本處理工具-PPT做業題

2、答案

一、linux

[root@c7e-uscwifi ~]#ifconfig ens33 | grep sk | tr -s '
192.168.38.131

二、bash

[root@c7e-uscwifi ~]#df -h | tr -s ' ' | cut -d' ' -f5 
nr | head -1
100

三、ide

[root@c7e-uscwifi ~]#cut -d: -f3 /etc/passwd | sort -rn
65534

四、工具

[root@c7e-uscwifi ~]#ll -d /tmp
drwxrwxrwt. 12 root root 246 Jul 30 14:47 /tmp
# 數字表示 4777

五、spa

[root@c7e-uscwifi ~]#w | grep pts | awk '{print $3}' | 
r
      2 192.168.38.1:S.0
      1 192.168.38.1
      1 172.18.28.28

六、3d

[root@c7e-uscwifi ~]#cat /proc/meminfo | grep -Ei '^s'
SwapCached:          176 kB
SwapTotal:       4194300 kB
SwapFree:        4192500 kB
Shmem:             17840 kB
Slab:             169748 kB
SReclaimable:      79592 kB
SUnreclaim:        90156 kB
[root@c7e-uscwifi ~]#cat /proc/meminfo | grep ^[sS].* 
SwapCached:          176 kB
SwapTotal:       4194300 kB
SwapFree:        4192500 kB
Shmem:             17840 kB
Slab:             169748 kB
SReclaimable:      79592 kB
SUnreclaim:        90156 kB

七、code

[root@c7e-uscwifi ~]#grep -Ev '/bin/bash$' /etc/passwd

八、blog

# rpc開頭的有兩個用戶
[root@c7e-uscwifi ~]#grep ^rpc: /etc/passwd | cut -d: -
/sbin/nologin

九、rpc

[root@c7e-uscwifi ~]#grep -Eo '\<[1-9][0-9]{1,2}\>' /etc/passwd

十、get

[root@c7e-uscwifi ~]#grep -E '^[[:space:]]+[^[:space:]]' /etc/grub2.cfg       |
  load_env                                                                    |
   set default="${next_entry}"                                                |
   set next_entry=                                                            |
   save_env next_entry                                                        |
   set boot_once=true

十一、

[root@c7e-uscwifi ~]#netstat -tan | grep -E 'LISTEN[[:space:]]+$'

十二、

[root@c7e-uscwifi ~]#cut -d: -f1,3 /etc/passwd | grep -E '\<[0-9]{1,3}\>'

1三、考察grep分組

[root@c7e-uscwifi ~]#cat useradd.sh 
user='bash testbash basher sh nologin'
for i in ${user}
do
    useradd $i
done
usermod -s /sbin/nologin nologin
[root@c7e-uscwifi ~]#getent passwd bash testbash basher sh nologin            |
bash:x:8017:8019::/home/bash:/bin/bash
testbash:x:8018:8020::/home/testbash:/bin/bash
basher:x:8019:8021::/home/basher:/bin/bash
sh:x:8020:8022::/home/sh:/bin/bash
nologin:x:8021:8023::/home/nologin:/sbin/nologin
#開始找
[root@c7e-uscwifi ~]#grep -E '^(.*):.*\1$' /etc/passwd                        |
sync:x:5:0:sync:/sbin:/bin/sync                                               |
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown                                  |
halt:x:7:0:halt:/sbin:/sbin/halt                                              |
bash:x:8017:8019::/home/bash:/bin/bash                                        |
sh:x:8020:8022::/home/sh:/bin/bash                                            |
nologin:x:8021:8023::/home/nologin:/sbin/nologin

1四、

[root@c7e-uscwifi ~]#df -h | grep -oE '[0-9]+%' | grep -oE '\<[0-9]+\>' | sort|
 -nr                                                                          |
100
8
5
2
1
1
0
0
0
0

1五、

[root@c7e-uscwifi ~]#grep -E "^mage:|^wang:|^root:" /etc/passwd | cut -d: -f1,
3,7                                                                           |
root:0:/bin/bash
mage:8005:/bin/bash
wang:8014:/bin/bash
[root@c7e-uscwifi ~]#egrep "^(root|mage|wang):" /etc/passwd|cut -d: -f1,3,7   |
root:0:/bin/bash
mage:8005:/bin/bash
wang:8014:/bin/bash

1六、

[root@c7e-uscwifi ~]#egrep  '\<.*\>\(\)' /etc/rc.d/init.d/functions
[root@c7e-uscwifi ~]#grep -E  "^[[:alpha:]_]+\(\)" /etc/rc.d/init.d/functions

1七、

[root@c7e-uscwifi ~]#echo '/etc/rc.d/init.d/functions' | egrep -o '[^/]+$'    |
functions   
[root@c7e-uscwifi ~]#echo /etc/rc.d/init.d/functions|egrep -o "[^/]+/?$"      |
functions

1八、

[root@c7e-uscwifi ~]#echo '/etc/rc.d/init.d/functions' | egrep -o '.*/'       |
/etc/rc.d/init.d/
[root@c7e-uscwifi ~]#echo /etc/rc.d/init.d/functions|egrep -o '^/.*/'         |
/etc/rc.d/init.d/

1九、

[root@c7e-uscwifi ~]#last | grep ^root | awk '{print $3}' | sort | uniq -c    |
      4 172.18.28.28
      2 172.18.28.7
      2 192.168.38.1
      9 :0
      1 Fri
      1 Sat

20、

[0-9]
[1-9][0-9]
1[0-9]{2}
2[0-4][0-9]
25[0-5]

2一、

[root@c7e-uscwifi ~]#ifconfig | grep -Eo '([0-9]+\.){3}[0-9]+'                |
192.168.38.131                                                                |
255.255.0.0                                                                   |
192.168.255.255                                                               |
172.18.145.72                                                                 |
255.255.0.0                                                                   |
172.18.255.255                                                                |
127.0.0.1                                                                     |
255.0.0.0                                                                     |
192.168.122.1                                                                 |
255.255.255.0                                                                 |
192.168.122.255

2二、

[root@c7e-uscwifi ~]#echo 'welcome to magedu linux' | egrep -o '[[:alpha:]]| '|
 | sort | uniq -c | sort -r                                                   |
      3 e
      3  
      2 u
      2 o
      2 m
      2 l
      1 x
      1 w
      1 t
      1 n
      1 i
      1 g
      1 d
      1 c
      1 a

2三、

[root@c7e-uscwifi ~]#sed 's@^\([[:space:]]\+\)\(.*\)@\2@g' /tmp/profile | wc -
l 
# -i選項修改文件

2四、

[root@c7e-uscwifi ~]#cp /etc/rc.d/init.d/functions /tmp  
[root@c7e-uscwifi ~]#sed 's@^\([[:space:]]\+\)\(.*\)@\#\1\2@g' /tmp/profile

2五、

set tabstop=4

2六、

[root@c7e-uscwifi ~]#sed 's@/etc/sysconfig/init@/var/log@g' /tmp/functions -i

2七、

:%s@^#\([[:space:]]\+.*\)@\1@g

2八、

相關文章
相關標籤/搜索