[Shell art] Only when it is a multiple of 3 and a number with 3 becomes stupid

【Overview】

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 /`.

【environment】

[vagrant@vagrant-centos65 ~]$ cat /etc/redhat-release 
CentOS release 6.5 (Final)

【code】

for i in `seq 40`; do echo $i | awk '{ if ($0 ~ /3/ || $0 % 3 == 0) print "Stupid"; else print }'; done

【Execution result】

[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

[Shell art] Only when it is a multiple of 3 and a number with 3 becomes stupid
Image processing with Python (I tried binarizing it into a mosaic art of 0 and 1)
Try to find the probability that it is a multiple of 3 and not a multiple of 5 when one is removed from a card with natural numbers 1 to 100 using Ruby and Python.
A script that pings the registered server and sends an email with Gmail a certain number of times when it fails
What to do when a part of the background image becomes transparent when the transparent image is combined with Pillow
Is it possible to enter a venture before listing and make a lot of money with stock options?
I wanted to know the number of lines in multiple files, so I tried to get it with a command
It is more convenient to use csv-table when writing a table with python-sphinx
Judge whether it is a prime number [Python]
If you define a method in a Ruby class and define a method in it, it becomes a method of the original class.
[Python Data Frame] When the value is empty, fill it with the value of another column.
A script that combines margins when pasting a number of graphs on tiles with gnuplot
When reading a csv file with read_csv of pandas, the first column becomes index
[It was a specification of curl & HTTP] When Flask with uWSGI is run by HTTP, there is a clean delay of 1 second when posting a file.
Two solutions to the problem that it is hard to see the vector field when writing a vector field with quiver () of matplotlib pyplot
Accelerate a large number of simple queries with MySQL
Create a batch of images and inflate with ImageDataGenerator
A server that returns the number of people in front of the camera with bottle.py and OpenCV
Get the matched string with a regular expression and reuse it when replacing on Python3
When I deploy a Django app with Apache2 and it no longer reads static files
Extract only the sound of a specific instrument from a MIDI file and make it a separate file
Lambda + Python is good at restricting access with a large number of IP address lists
[Python] What is a tuple? Explains how to use without tuples and how to use it with examples.
[Graph drawing] I tried to write a bar graph of multiple series with matplotlib and seaborn