Download - Unix study class_01
+
Unix study class May,16Ryota
+Windows and Mac
Graphical User Interface
Application is your solution.
Guaranteed quality.You must pay to use them.Made by corporations.
+Unix and Unix-like OS(Linux)
Terminal.
Your program is your solution. bash
Highly flexible.Free.Made by communities.
+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?
+Shell allows you to communicate with the OS
Shell
OS
Every OS has its shell.Windows -> explorer.exeMac -> 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.
+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
+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”
+
hello world⬇️
helle werld
Pipe connects the commands.
echo “hello world” | tr “o” “e”
hello worldstdout stdin
stdout
pipe
+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”
+More commands: cat
$ cat file_abaconspampizza
$ cat file_a file_bbaconspampizzatomatopotatolettuce
$ cat file_btomatopotatolettuce
concatenate and print files.
There is files named file_a and file_b.
+More commands: sort
$ sort file_a file_bbaconlettucepizzapotatospamtomato
Write sorted concatenation of files to standard output.
sort can read from standard input.cat file_a file_b | sortThis command works same.
Alphabeticallysorted
+More commands: cut
$ cat agesryota sugimoto 29takahide hayano 35itsuro inoue 58hirofumi nakaoka 34waleed omer 35shiro yamada 48kazuyoshi hosomichi 36
$ cut -f 3 ages29355534354836
cut out selected portions of each line of a file.
All values in this table are fiction.
+More commands: uniq
$ cat file_cabbcaddd
$ uniq file_cabcad
report or filter out repeated lines in a file.
+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.