For numbers from 1 to 40, the character string "stupid" is output only when the number is a multiple of 3 and the number has 3.
Otherwise, it outputs numbers.
The point is that ʻawkuses the regular expression
/3 /`.
[vagrant@vagrant-centos65 ~]$ cat /etc/redhat-release
CentOS release 6.5 (Final)
for i in `seq 40`; do echo $i | awk '{ if ($0 ~ /3/ || $0 % 3 == 0) print "Stupid"; else print }'; done
[vagrant@vagrant-centos65 ~]$ for i in `seq 40`; do echo $i | awk '{ if ($0 ~ /3/ || $0 % 3 == 0) print "Stupid"; else print }'; done
1
2
Stupid
4
5
Stupid
7
8
Stupid
10
11
Stupid
Stupid
14
Stupid
16
17
Stupid
19
20
Stupid
22
Stupid
Stupid
25
26
Stupid
28
29
Stupid
Stupid
Stupid
Stupid
Stupid
Stupid
Stupid
Stupid
Stupid
Stupid
40
[vagrant@vagrant-centos65 ~]$
Recommended Posts