{"id":8970,"date":"2024-05-19T12:01:01","date_gmt":"2024-05-19T04:01:01","guid":{"rendered":""},"modified":"2024-05-19T12:01:01","modified_gmt":"2024-05-19T04:01:01","slug":"linux geep\u547d\u4ee4,sed,grep,awk\u662f\u4e09\u4e2a\u5f88\u5b9e\u7528\u7684\u6587\u5b57\u5904\u7406\u547d\u4ee4","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8970.html","title":{"rendered":"linux geep\u547d\u4ee4,sed,grep,awk\u662f\u4e09\u4e2a\u5f88\u5b9e\u7528\u7684\u6587\u5b57\u5904\u7406\u547d\u4ee4"},"content":{"rendered":"
sed,grep,awk\u662f\u4e09\u4e2a\u5f88\u5b9e\u7528\u7684\u6587\u5b57\u5904\u7406\u547d\u4ee4\uff0c\u4ed6\u4eec\u80fd\u548c\u6b63\u5219\u8868\u8fbe\u5f0f\u80fd\u591f\u5f88\u591a\u7684\u7ed3\u5408\uff0c\u8ba9\u4f60\u7684\u811a\u672c\u641c\u7d22\u663e\u73b0\u51fa\u5f3a\u5927\u7684\u80fd\u529b\u3002<\/p>\n
1.<\/p>\n
\u6b63\u5219\u8868\u8fbe\u5f0f\uff1a<\/p>\n
\u5e38\u7528\u7684\u5143\u5b57\u7b26<\/p>\n
.<\/p>\n
\u5339\u914d\u9664\u6362\u884c\u7b26\u4ee5\u5916\u7684\u4efb\u610f\u5b57\u7b26<\/p>\n
\\w\u5339\u914d\u5b57\u6bcd\u6216\u6570\u5b57\u6216\u4e0b\u5212\u7ebf\u6216\u6c49\u5b57<\/p>\n
\\s<\/p>\n
\u5339\u914d\u4efb\u610f\u7684\u7a7a\u767d\u7b26<\/p>\n
\\d<\/p>\n
\u5339\u914d\u6570\u5b57<\/p>\n
\\b<\/p>\n
\u5339\u914d\u5355\u8bcd\u7684\u5f00\u59cb\u6216\u7ed3\u675f<\/p>\n
\u4ee5\u4e0a\u5143\u5b57\u7b26\u5b57\u6bcd\u53d8\u4e3a\u5927\u5199\u60f3\u53cd\u5339\u914d<\/p>\n
^<\/p>\n
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u59cb<\/p>\n
$<\/p>\n
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u675f<\/p>\n
[^x]\u5339\u914d\u9664\u4e86x\u4ee5\u5916\u7684\u4efb\u610f\u5b57\u7b26[^aeiou]\u5339\u914d\u9664\u4e86aeiou\u8fd9\u51e0\u4e2a\u5b57\u6bcd\u4ee5\u5916\u7684\u4efb\u610f\u5b57\u7b26<\/p>\n
\u5e38\u7528\u9650\u5b9a\u7b26<\/p>\n
*<\/p>\n
\u91cd\u590d\u96f6\u6b21\u6216\u66f4\u591a\u6b21<\/p>\n
+<\/p>\n
\u91cd\u590d\u4e00\u6b21\u6216\u66f4\u591a\u6b21<\/p>\n
?<\/p>\n
\u91cd\u590d\u96f6\u6b21\u6216\u4e00\u6b21<\/p>\n
{n}<\/p>\n
\u91cd\u590dn\u6b21<\/p>\n
{n,}<\/p>\n
\u91cd\u590dn\u6b21\u6216\u66f4\u591a\u6b21<\/p>\n
{n,m}<\/p>\n
\u91cd\u590dn\u5230m\u6b21<\/p>\n
*?\u91cd\u590d\u4efb\u610f\u6b21\uff0c\u4f46\u5c3d\u53ef\u80fd\u5c11\u91cd\u590d+?\u91cd\u590d1\u6b21\u6216\u66f4\u591a\u6b21\uff0c\u4f46\u5c3d\u53ef\u80fd\u5c11\u91cd\u590d??<\/p>\n
\u91cd\u590d0\u6b21\u62161\u6b21\uff0c\u4f46\u5c3d\u53ef\u80fd\u5c11\u91cd\u590d{n,m}?<\/p>\n
\u91cd\u590dn\u5230m\u6b21\uff0c\u4f46\u5c3d\u53ef\u80fd\u5c11\u91cd\u590d{n,}?<\/p>\n
\u91cd\u590dn\u6b21\u4ee5\u4e0a\uff0c\u4f46\u5c3d\u53ef\u80fd\u5c11\u91cd\u590d<\/p>\n
\u6355\u83b7(exp) \u5339\u914dexp,\u5e76\u6355\u83b7\u6587\u672c\u5230\u81ea\u52a8\u547d\u540d\u7684\u7ec4\u91cc(?exp)\u5339\u914dexp,\u5e76\u6355\u83b7\u6587\u672c\u5230\u540d\u79f0\u4e3aname\u7684\u7ec4\u91cc\uff0c\u4e5f\u53ef\u4ee5\u5199\u6210(?'name'exp)<\/p>\n
(?:exp)<\/p>\n
\u5339\u914dexp,\u4e0d\u6355\u83b7\u5339\u914d\u7684\u6587\u672c\uff0c\u4e5f\u4e0d\u7ed9\u6b64\u5206\u7ec4\u5206\u914d\u7ec4\u53f7\u4f4d\u7f6e\u6307\u5b9a(?=exp)<\/p>\n
\u5339\u914dexp\u524d\u9762\u7684\u4f4d\u7f6e(?<=exp)\u5339\u914dexp\u540e\u9762\u7684\u4f4d\u7f6e(?!exp)<\/p>\n
\u5339\u914d\u540e\u9762\u8ddf\u7684\u4e0d\u662fexp\u7684\u4f4d\u7f6e(?\u5339\u914d\u524d\u9762\u4e0d\u662fexp\u7684\u4f4d\u7f6e\u6ce8\u91ca(?#comment) \u8fd9\u79cd\u7c7b\u578b\u4e0d\u5bf9\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5904\u7406\u4ea7\u751f\u4efb\u4f55\u5f71\u54cd\uff0c\u7528\u4e8e\u63d0\u4f9b\u6ce8\u91ca\u8ba9\u4eba\u9605\u8bfb\u5176\u5b83\u8868\u8fbe\u5f0f<\/p>\n
\\a<\/p>\n
\u62a5\u8b66\u5b57\u7b26(\u6253\u5370\u5b83\u7684\u6548\u679c\u662f\u7535\u8111\u5600\u4e00\u58f0)<\/p>\n
\\b \u901a\u5e38\u662f\u5355\u8bcd\u5206\u754c\u4f4d\u7f6e\uff0c\u4f46\u5982\u679c\u5728\u5b57\u7b26\u7c7b\u91cc\u4f7f\u7528\u4ee3\u8868\u9000\u683c\\t \u5236\u8868\u7b26\uff0cTab<\/p>\n
\\r \u56de\u8f66\\v \u7ad6\u5411\u5236\u8868\u7b26\\f \u6362\u9875\u7b26\\n \u6362\u884c\u7b26\\e Escape<\/p>\n
\\0nn ASCII\u4ee3\u7801\u4e2d\u516b\u8fdb\u5236\u4ee3\u7801\u4e3ann\u7684\u5b57\u7b26\\xnn ASCII\u4ee3\u7801\u4e2d\u5341\u516d\u8fdb\u5236\u4ee3\u7801\u4e3ann\u7684\u5b57\u7b26\\unnnn Unicode\u4ee3\u7801\u4e2d\u5341\u516d\u8fdb\u5236\u4ee3\u7801\u4e3annnn\u7684\u5b57\u7b26\\cN ASCII\u63a7\u5236\u5b57\u7b26\u3002\u6bd4\u5982\\cC\u4ee3\u8868Ctrl+C<\/p>\n
\\A \u5b57\u7b26\u4e32\u5f00\u5934(\u7c7b\u4f3c^\uff0c\u4f46\u4e0d\u53d7\u5904\u7406\u591a\u884c\u9009\u9879\u7684\u5f71\u54cd)<\/p>\n
\\Z \u5b57\u7b26\u4e32\u7ed3\u5c3e\u6216\u884c\u5c3e(\u4e0d\u53d7\u5904\u7406\u591a\u884c\u9009\u9879\u7684\u5f71\u54cd)<\/p>\n
\\z \u5b57\u7b26\u4e32\u7ed3\u5c3e(\u7c7b\u4f3c$\uff0c\u4f46\u4e0d\u53d7\u5904\u7406\u591a\u884c\u9009\u9879\u7684\u5f71\u54cd)<\/p>\n
\\G \u5f53\u524d\u641c\u7d22\u7684\u5f00\u5934<\/p>\n
grep<\/p>\n
grep\u683c\u5f0f\uff1a<\/p>\n
grep [\u9009\u9879]\u57fa\u672c\u6b63\u5219\u8868\u8fbe\u5f0f[\u6587\u4ef6]<\/p>\n
\u8fd9\u91cc\u57fa\u672c\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4e3a\u5b57\u7b26\u4e32\u3002<\/p>\n
\u5728\u7528grep\u8fdb\u884c\u67e5\u8be2\u65f6\u6ce8\u610f\u4e8b\u9879\uff1a<\/p>\n
1.<\/p>\n
\u67e5\u8be2\u5b57\u7b26\u4e32\u7279\u522b\u662f\u591a\u4e2a\u5b57\u7b26\u65f6\u5e94\u8be5\u7528\u201c\u201d\uff0c\u5982 grep \u201clinuxdn\u201d \u8fd9\u6837\u505a\u7684\u597d\u5904\u6709\u4e24\u4e2a\uff0c\u4e00\u662f\u9632\u6b62\u88ab\u8bef\u8ba4\u4e3ashell\u547d\u4ee4\uff1b\u4e8c\u662f\u9632\u6b62\u88ab\u8bef\u8ba4\u4e3a\u6587\u4ef6\uff0c\u5982<\/p>\n
grep linuxdn dd\u67e5\u8be2\u7ed3\u679c\u53ef\u80fd\u4e3a\u201d No such file or<\/p>\n
directory\u201d.<\/p>\n
2.<\/p>\n
\u5728\u8c03\u7528\u53d8\u91cf\u4e5f\u8981\u4f7f\u7528\u53cc\u5f15\u53f7\uff0c\u8bf8\u5982\uff1agrep \u201c$linuxdn\u201d<\/p>\n
file\uff0c\u5982\u679c\u4e0d\u8fd9\u6837\uff0c\u5c06,\u6ca1\u6709\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n
3.<\/p>\n
\u5728\u8c03\u7528\u6a21\u5f0f\u5339\u914d\u65f6\uff0c\u5e94\u4f7f\u7528\u5355\u5f15\u53f7\u5982 grep \u2018l\u2026n\u2019 file.<\/p>\n
4.<\/p>\n
\u67e5\u8be2\u7279\u6b8a\u5b57\u7b26\u8fdb\u8981\u7528\\<\/p>\n
grep\u9009\u9879<\/p>\n
\u5e38\u7528\u9009\u9879<\/p>\n
-c \u53ea\u8f93\u51fa\u5339\u914d\u884c\u7684\u8ba1\u6570\u3002<\/p>\n
-i \u4e0d\u533a\u5206\u5927\u5c0f\u5199(\u53ea\u9002\u7528\u4e8e\u5355\u5b57\u7b26)\u3002<\/p>\n
-h \u67e5\u8be2\u591a\u6587\u4ef6\u65f6\u4e0d\u663e\u793a\u6587\u4ef6\u540d\u3002<\/p>\n
-l \u67e5\u8be2\u591a\u6587\u4ef6\u65f6\u53ea\u8f93\u51fa\u5305\u542b\u5339\u914d\u5b57\u7b26\u7684\u6587\u4ef6\u540d\u3002<\/p>\n
-n \u663e\u793a\u5339\u914d\u884c\u53ca\u884c\u53f7\u3002<\/p>\n
-s \u4e0d\u663e\u793a\u4e0d\u5b58\u5728\u6216\u65e0\u5339\u914d\u6587\u672c\u7684\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n
-v \u663e\u793a\u4e0d\u5305\u542b\u5339\u914d\u6587\u672c\u7684\u6240\u6709\u884c\u3002<\/p>\n
\u5176\u5b83\u9009\u9879<\/p>\n
-a \u5ffd\u7565\u4e8c\u8fdb\u5236\u6570\u636e<\/p>\n
-A \u641c\u7d22\u7b26\u5408\u5b57\u7b26\u4e32\u540e\u4f9d\u6307\u5b9a\u884c\u6570\u4e4b\u540e\u884c\u6570\u7684\u6240\u6709\u663e\u793a<\/p>\n
-b \u663e\u793a\u7b26\u5408\u6a21\u677f\u6837\u5f0f\u7684\u524d\u4e00\u884c\uff0c\u6807\u51fa\u7b2c\u4e00\u4e2a\u5b57\u7684\u4f4d\u7f6e<\/p>\n
-B\u641c\u7d22\u7b26\u5408\u5b57\u7b26\u4e32\u540e\u4f9d\u6307\u5b9a\u884c\u6570\u4e4b\u524d\u884c\u6570\u7684\u6240\u6709\u663e\u793a<\/p>\n
-C \u8f93\u51fa\u5339\u914d\u884c\u7684\u8ba1\u6570\u4e0e\u4e4b\u540e\u6307\u5b9a\u884c\u7684\u884c\u6570\u5185\u5bb9<\/p>\n
-d \u6307\u5b9a\u641c\u7d22\u7684\u4e3a\u76ee\u5f55<\/p>\n
-e \u641c\u7d22\u6307\u5b9a\u5b57\u7b26\u4e32\u7684\u6587\u4ef6\u5185\u5bb9(\u6a21\u677f\u6837\u5f0f)<\/p>\n
-E\u641c\u7d22\u6307\u5b9a\u5b57\u7b26\u4e32\u7684\u6587\u4ef6\u5185\u5bb9(\u666e\u901a\u8868\u793a\u6cd5)<\/p>\n
-f \u6307\u5b9a\u6a21\u677f\u6587\u4ef6<\/p>\n
-F \u6a21\u677f\u6837\u5f0f\u4e3a\u56fa\u5b9a\u5b57\u7b26\u4e32\u5217\u8868<\/p>\n
-G\u6a21\u677f\u6837\u5f0f\u4e3a\u666e\u901a\u5217\u8868<\/p>\n
-H\u67e5\u8be2\u591a\u6587\u4ef6\u65f6\u663e\u793a\u6587\u4ef6\u540d<\/p>\n
-I \u5217\u51fa\u6587\u4ef6\u5185\u5bb9\u7b26\u5408\u6307\u5b9a\u6a21\u677f\u7684\u6587\u4ef6\u540d<\/p>\n
-L\u5217\u51fa\u6587\u4ef6\u5185\u5bb9\u4e0d\u7b26\u5408\u6307\u5b9a\u6a21\u677f\u7684\u6587\u4ef6\u540d<\/p>\n
-q \u4e0d\u663e\u793a\u4efb\u4f55\u4fe1\u606f<\/p>\n
-V\u663e\u793a\u7248\u672c\u4fe1\u606f<\/p>\n
-y \u4e0e-I\u76f8\u540c<\/p>\n
--help \u5e2e\u52a9\u4fe1\u606f<\/p>\n
grep \u4e3e\u4f8b\u8bf4\u660e<\/p>\n
\u6709interface\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n
# and how to activate them. For more<\/p>\n
information, see interfaces(5).<\/p>\n
# The loopback network<\/p>\n
interface<\/p>\n
auto lo eth1<\/p>\n
iface lo inet loopback<\/p>\n
# The primary network<\/p>\n
interface<\/p>\n
allow-hotplug eth0<\/p>\n
iface eth0 inet static<\/p>\n
address 193.168.20.203<\/p>\n
netmask 255.255.255.0<\/p>\n
network 193.168.20.0<\/p>\n
broadcast 193.168.20.255<\/p>\n
gateway 193.168.20.1<\/p>\n
# dns-* options are implemented by the resolvconf package, if<\/p>\n
installed<\/p>\n
dns-nameservers 202.106.0.20<\/p>\n
dns-search rising.com.cn<\/p>\n
iface eth1 inet static<\/p>\n
address 192.168.110.148<\/p>\n
netmask 255.255.255.0<\/p>\n
\u6709passwd \u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n
root:x:0:0:root:\/root:\/bin\/bash<\/p>\n
daemon:x:1:1:daemon:\/usr\/sbin:\/bin\/sh<\/p>\n
bin:x:2:2:bin:\/bin:\/bin\/sh<\/p>\n
sys:x:3:3:sys:\/dev:\/bin\/sh<\/p>\n
sync:x:4:65534:sync:\/bin:\/bin\/sync<\/p>\n
games:x:5:60:games:\/usr\/games:\/bin\/sh<\/p>\n
man:x:6:12:man:\/var\/cache\/man:\/bin\/sh<\/p>\n
lp:x:7:7:lp:\/var\/spool\/lpd:\/bin\/sh<\/p>\n
mail:x:8:8:mail:\/var\/mail:\/bin\/sh<\/p>\n
news:x:9:9:news:\/var\/spool\/news:\/bin\/sh<\/p>\n
uucp:x:10:10:uucp:\/var\/spool\/uucp:\/bin\/sh<\/p>\n
proxy:x:13:13:proxy:\/bin:\/bin\/sh<\/p>\n
www-data:x:33:33:www-data:\/var\/www:\/bin\/sh<\/p>\n
backup:x:34:34:backup:\/var\/backups:\/bin\/sh<\/p>\n
list:x:38:38:Mailing List<\/p>\n
Manager:\/var\/list:\/bin\/sh<\/p>\n
irc:x:39:39:ircd:\/var\/run\/ircd:\/bin\/sh<\/p>\n
gnats:x:41:41:Gnats Bug-Reporting<\/p>\n
System (admin):\/var\/lib\/gnats:\/bin\/sh<\/p>\n
nobody:x:65534:65534:nobody:\/nonexistent:\/bin\/sh<\/p>\n
rising:x:1000:1000:rising,,,:\/home\/rising:\/bin\/bash<\/p>\n
sshd:x:100:65534::\/var\/run\/sshd:\/usr\/sbin\/nologin<\/p>\n
mysql:x:101:103:MySQL<\/p>\n
Server,,,:\/var\/lib\/mysql:\/bin\/false<\/p>\n
Debian-exim:x:102:104::\/var\/spool\/exim4:\/bin\/false<\/p>\n
ftp:x:103:65534::\/home\/ftp:\/bin\/false<\/p>\n
1.<\/p>\n
\u5728\u591a\u4e2a\u6587\u4ef6\u4e2d\u67e5\u8be2\u5b57\u7b26\u4e32<\/p>\n
\u5982\u679c\u8981\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u6240\u6709.txt\u6587\u4ef6\u4e2d\u67e5\u627e\u5b57\u7b26\u4e32\u201c<\/p>\n
linuxdn\u201d\uff0c\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n
# grep \"linuxdn\" *.txe<\/p>\n
\u6216\u5728\u6240\u6709\u6587\u4ef6\u4e2d\u67e5\u8be2\u5355\u8bcd\u201c linuxdn<\/p>\n
\u201d<\/p>\n
# grep \"linuxdn\" *<\/p>\n
2.<\/p>\n
\u884c\u5339\u914d<\/p>\n
\u67e5\u8be2# grep -c \"1\" passwd<\/p>\n
10<\/p>\n
grep\u8fd4\u56de\u6570\u5b5710\uff0c\u610f\u4e49\u662f\u670910\u884c\u5305\u542b\u5b57\u7b26\u4e32\u201c1\u201d\u3002<\/p>\n
3.<\/p>\n
\u663e\u793a\u663e\u793a\u6ee1\u8db3\u5339\u914d\u6a21\u5f0f\u7684\u6240\u6709\u884c\u884c\u6570<\/p>\n
#grep -n \"1\" passwd<\/p>\n
2:daemon:x:1:1:daemon:\/usr\/sbin:\/bin\/sh<\/p>\n
7:man:x:6:12:man:\/var\/cache\/man:\/bin\/sh<\/p>\n
11:uucp:x:10:10:uucp:\/var\/spool\/uucp:\/bin\/sh<\/p>\n
12:proxy:x:13:13:proxy:\/bin:\/bin\/sh<\/p>\n
17:gnats:x:41:41:Gnats Bug-Reporting<\/p>\n
System (admin):\/var\/lib\/gnats:\/bin\/sh<\/p>\n
19:rising:x:1000:1000:rising,,,:\/home\/rising:\/bin\/bash<\/p>\n
20:sshd:x:100:65534::\/var\/run\/sshd:\/usr\/sbin\/nologin<\/p>\n
21:mysql:x:101:103:MySQL<\/p>\n
Server,,,:\/var\/lib\/mysql:\/bin\/false<\/p>\n
22:Debian-exim:x:102:104::\/var\/spool\/exim4:\/bin\/false<\/p>\n
23:ftp:x:103:65534::\/home\/ftp:\/bin\/false<\/p>\n
4.<\/p>\n
\u663e\u793a\u975e\u5339\u914d\u884c<\/p>\n
#grep \u2013v \"1\" passwd<\/p>\n
root:x:0:0:root:\/root:\/bin\/bash<\/p>\n
bin:x:2:2:bin:\/bin:\/bin\/sh<\/p>\n
sys:x:3:3:sys:\/dev:\/bin\/sh<\/p>\n
sync:x:4:65534:sync:\/bin:\/bin\/sync<\/p>\n
games:x:5:60:games:\/usr\/games:\/bin\/sh<\/p>\n
lp:x:7:7:lp:\/var\/spool\/lpd:\/bin\/sh<\/p>\n
mail:x:8:8:mail:\/var\/mail:\/bin\/sh<\/p>\n
news:x:9:9:news:\/var\/spool\/news:\/bin\/sh<\/p>\n
www-data:x:33:33:www-data:\/var\/www:\/bin\/sh<\/p>\n
backup:x:34:34:backup:\/var\/backups:\/bin\/sh<\/p>\n
list:x:38:38:Mailing List<\/p>\n
Manager:\/var\/list:\/bin\/sh<\/p>\n
irc:x:39:39:ircd:\/var\/run\/ircd:\/bin\/sh<\/p>\n
nobody:x:65534:65534:nobody:\/nonexistent:\/bin\/sh<\/p>\n
5.<\/p>\n
\u7cbe\u786e\u5339\u914d<\/p>\n
\u4f7f\u7528geep\u7cbe\u786e\u5339\u914d\u65b9\u5f0f\u662f\u5728\u62bd\u53d6\u5b57\u7b26\u4e32\u540e\u52a0\\ >\u5047\u5b9a\u5728interface\u4e2d\u7cbe\u786e\u62bd\u53d6\u542b\u6709203\u7684\u4e00\u884c<\/p>\n
\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n
#grep '203\\>'<\/p>\n
interfaces<\/p>\n
address 193.168.20.203<\/p>\n
6.<\/p>\n
\u5e26\u8303\u56f4\u5339\u914d<\/p>\n
\u5982\u5728interfacek \u67e5\u627e\u542b\u6709192 \u548c 193 \u7684\u884c<\/p>\n
#grep '19[23]' interfaces<\/p>\n
address 193.168.20.203<\/p>\n
network 193.168.20.0<\/p>\n
broadcast 193.168.20.255<\/p>\n
gateway 193.168.20.1<\/p>\n
address<\/p>\n
192.168.110.148<\/p>\n
7.<\/p>\n
\u5e26\u5143\u5b57\u7b26\u67e5\u8be2<\/p>\n
\u67e5\u8be2interface\u9996\u884c\u662fallow<\/p>\n
#grep '^allow' interfaces<\/p>\n
allow-hotplug eth0<\/p>\n
\u67e5\u8be2\u9996\u884c\u4e0d\u662faddress<\/p>\n
#grep '^[^address]'<\/p>\n
interfaces<\/p>\n
# This file describes the network<\/p>\n
interfaces available on your system<\/p>\n
# and how to activate them. For more<\/p>\n
information, see interfaces(5).<\/p>\n
# The loopback network<\/p>\n
interface<\/p>\n
iface lo inet loopback<\/p>\n
# The primary network<\/p>\n
interface<\/p>\n
iface eth0 inet static<\/p>\n
address 193.168.20.203<\/p>\n
netmask 255.255.255.0<\/p>\n
network 193.168.20.0<\/p>\n
broadcast 193.168.20.255<\/p>\n
gateway 193.168.20.1<\/p>\n
# dns-* options are implemented by the resolvconf package, if<\/p>\n
installed<\/p>\n
dns-nameservers 202.106.0.20<\/p>\n
dns-search rising.com.cn<\/p>\n
iface eth1 inet static<\/p>\n
address 192.168.110.148<\/p>\n
netmask<\/p>\n
255.255.255.0<\/p>\n
8.<\/p>\n
\u6b21\u6570\u67e5\u8be2\u76f8\u5173\u5185\u5bb9<\/p>\n
\u67e5\u8be2interface\u4e2dl\u51fa\u73b0\u67092\u6b21\u7684\u884c<\/p>\n
#grep 'l\\{2,\\}' interfaces<\/p>\n
allow-hotplug eth0<\/p>\n
# dns-* options are implemented by the resolvconf package, if<\/p>\n
installed<\/p>\n
9.<\/p>\n
grep \u5229\u7528\u4e0e\uff0c\u6216\u64cd\u4f5c<\/p>\n
\u67e5\u8be2193\u6216192\u51fa\u73b0\u7684\u884c<\/p>\n
#grep -E '192|193'<\/p>\n
interfaces<\/p>\n
address 193.168.20.203<\/p>\n
network 193.168.20.0<\/p>\n
broadcast 193.168.20.255<\/p>\n
gateway 193.168.20.1<\/p>\n
address<\/p>\n
192.168.110.148<\/p>\n
10.<\/p>\n
\u67e5\u8be2\u7a7a\u884c\uff0c\u53ef\u5229\u7528^ $\u8fdb\u884c\u67e5\u8be2<\/p>\n
#grep<\/p>\n
\u2018^$\u2019 interface<\/p>\n
11.<\/p>\n
\u5229\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u67e5\u8be2<\/p>\n
\u67e5\u8be2interface \u4e2d193.168.20.*\u7684IP<\/p>\n
#grep '193.168.20.[0-9]\\{1,3\\}'<\/p>\n
interfaces<\/p>\n
address 193.168.20.203<\/p>\n
network 193.168.20.0<\/p>\n
broadcast 193.168.20.255<\/p>\n
gateway 193.168.20.1<\/p>\n
12.<\/p>\n
\u5229\u7528\u7cfb\u7edf\u67e5\u8be2<\/p>\n
grep \u7684\u4e00\u4e2a\u5f3a\u5927\u529f\u80fd\u5c31\u662f\u548c\u4e00\u4e9b\u7cfb\u7edf\u547d\u4ee4\u7ed3\u5408\u4f7f\u7528\u6bd4\u5982ls,find,ps\u7b49\uff0c\u5173\u4e8e\u8fd9\u65b9\u9762\u4f8b\u5b50\u5c31\u592a\u591a\u4e86\uff0c\u6211\u5c31\u4e0d\u518d\u8bf4\u4e86\uff0c\u7b49\u5927\u5bb6\u5728\u5de5\u4f5c\u5b66\u4e60\u4e2d\u6162\u6162\u4f53\u4f1a\u5427\u3002<\/p>\n
\u4eca\u5929\u5f88\u7d2f\u4e86\u5199\u4e86\u8fd9\u4e48\u591a\uff0c\u53ef\u4ee5\u4f11\u606f\u4e00\u4f1a\u4e86\uff0c\u54c8\u54c8\u3002\u4ee5\u540e\u6211\u4eec\u518d\u8bf4\u5173\u4e8eawk\uff0c\u548csed\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"linux geep\u547d\u4ee4,sed,grep,awk\u662f\u4e09\u4e2a\u5f88\u5b9e\u7528\u7684\u6587\u5b57\u5904\u7406\u547d\u4ee4sed,grep,awk\u662f\u4e09\u4e2a\u5f88\u5b9e\u7528\u7684\u6587\u5b57\u5904\u7406\u547d\u4ee4\uff0c\u4ed6\u4eec\u80fd\u548c\u6b63\u5219\u8868\u8fbe\u5f0f\u80fd\u591f\u5f88...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8970"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8970"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8970\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}