Skip to content

Commit 0db6aa6

Browse files
authored
doc: update command/awk.md (#590)
1 parent 3454b8a commit 0db6aa6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

command/awk.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ awk 'NR%2==1{next}{print NR,$0;}' text.txt
371371

372372
当记录行号除以2余1,就跳过当前行。下面的`print NR,$0`也不会执行。下一行开始,程序有开始判断`NR%2`值。这个时候记录行号是`:2` ,就会执行下面语句块:`'print NR,$0'`
373373

374-
分析发现需要将包含有“web”行进行跳过,然后需要将内容与下面行合并为一行
374+
跳过以“web”为首的行,再将该行内容分别与下面不以“web”为首的行合并打印,使用一个“:”和一个制表符连接
375375

376376
```shell
377377
cat text.txt
@@ -386,7 +386,7 @@ web03[192.168.2.102]
386386
mysqld ok
387387
httpd ok
388388
0
389-
awk '/^web/{T=$0;next;}{print T":"t,$0;}' text.txt
389+
awk '/^web/{T=$0;next;}{print T":\t"$0;}' text.txt
390390
web01[192.168.2.100]: httpd ok
391391
web01[192.168.2.100]: tomcat ok
392392
web01[192.168.2.100]: sendmail ok

0 commit comments

Comments
 (0)