2. +
Windows and Mac
Graphical User Interface
Application is your solution.
Guaranteed quality.
You must pay to use them.
Made by corporations.
3. +
Unix and Unix-like OS(Linux)
Terminal.
Your program is your solution. bash
Highly flexible.
Free.
Made by communities.
4. +
But I can’t code a program myself…
I have no basis of math, algorithm or computer science and...
Fear not, for the communities with you.
Unix has
• a lot of Utilities
• a lot of Libraries
• a lot of web sites where professionals answer for you.
You don’t (always) need to code everything by yourself because
How do we use Unix utilities?
5. +
Shell allows you to communicate
with the OS
OS
Every OS has its shell.
Windows -> explorer.exe
Mac -> Finder
Unix -> bash
bash receives your command and execute it.
bash is programmable.
bash includes many utilities.
You almost always find bash on any Unix system.
6. +
The first command: echo
$ echo "hello world"
hello world
What is it actually doing?
Read the manual!
“It writes arguments to the standard output.”
What is standard output?
It’s the key to combine Unix utilities.
$ man echo
7. +
The second command: tr
$ echo "hello world" | tr "o" "e"
helle werld
“o” has been substituted for “e”.
In other words, translating.
manual says..
“tr copies the standard input to the standard
output with sub-stitution”
9. +
Training
2. echo “hello world” | tr “o” “e” | tr “h” “H” | tr “w” “W”
1. echo “spam” | tr “s” “z”
3. echo “tomato” | tr –d “o”
4. echo "hello world" | tr " " "n”
hint: n is a escaped character for newline
5. echo “hello world” | tr “lo” “ol”
10. +
More commands: cat
$ cat file_a
bacon
spam
pizza
$ cat file_a file_b
bacon
spam
pizza
tomato
potato
lettuce
$ cat file_b
tomato
potato
lettuce
concatenate and print files.
There is files named file_a and file_b.
11. +
More commands: sort
$ sort file_a file_b
bacon
lettuce
pizza
potato
spam
tomato
Write sorted concatenation of files to standard output.
sort can read from standard input.
cat file_a file_b | sort
This command works same.
Alphabetically
sorted
12. +
More commands: cut
$ cat ages
ryota sugimoto 29
takahide hayano 35
itsuro inoue 58
hirofumi nakaoka 34
waleed omer 35
shiro yamada 48
kazuyoshi hosomichi 36
$ cut -f 3 ages
29
35
55
34
35
48
36
cut out selected portions of each line of a file.
All values in this table are fiction.
13. +
More commands: uniq
$ cat file_c
a
b
b
c
a
d
d
d
$ uniq file_c
a
b
c
a
d
report or filter out repeated lines in a file.
14. +
Training
1. cat file_a | tr "a" "A" | cat - file_b
2. Remove all duplicating lines from file_c.
3. Sort ages file by their family name.
4. Count the number of each ages from ages file.
Hint: Use –c option of uniq command.