Class Session: Wednesday Aug 29, 2018
Be sure to bring your laptop to this session.
Don't forget about making blog posts or other parts of your Value Added grade component.
linux emulator: http://bellard.org/jslinux/ This is pretend. Nothing you create here is saved. Refresh your browser and it will disappear.
Command Line Text editors let you edit text directly on the server; when you work on a file and save it, it is done. There is no need to upload it with an FTP program. So if you mess up a file online, it is messed up; There is no backup on your laptop. In some cases, this could make your entire web server go down, depending on what you are editing. So if you are editing an important system file that is on the server, you should first make a backup by using the cp command. For example: cp index.html index-bkup.html
These editors will work on the mac Terminal for the Mac System as well as Opal (linux). In other words, you can use terminal to edit your Mac System files, so make sure you don't get too ambitious too soon with your new linux skills. If you mess up something on opal, it's not a big deal; you don't have any system file permissions. If you mess up your Mac, you could really be in bad shape. However this is not likely if you stay in your Mac User Directory. The worst thing that you can do there is wipe out a lot of files with the rm -r
remove command with the recursive flag.
The Windows command line editor is not linux, and it is not really DOS either, so you can't run linux commands on it.
To get some feel for linux capability on Windows, you can download gitbash for Windows, but it only has limited linux operability. If you want to try that, I know that it is not too difficult, because all of my Windows users in Fall 2017 set it up just fine. (I am not requiring it this semester because we are not using Carolina CloudApps for web hosting.) When installing, simply accept all of the default settings. This is totally optional.
It is possible to now install linux on Windows, but it is BETA mode, so don't take this on during this session of INLS 161 unless you are very motivated and technically comfortable with working with the Windows Command prompt. You will need to use the command line to set up Linux on Windows, and then, after setup, you could run Nano and Vim on Linux Subsystem for Windows. There is absolutely no reason to take this on for the purposes of this class.
rename hello.txt to README.md by using the mv (move command)
Below is a raw text file list of students listed by f_name
, l_name,
and then listed by fund-raising-collection totals for week one
, two
, three
, and four
.
See this file on my Google Docs Account
We will copy and paste this into a text file on the server using Nano, a command line text-editor. Then we will run a few awk text processing commands on the data and then demo some sorts. Sort(Unix) at Wikipedia
Bill Trumbell 56 56 56 67 Sharon King 57 78 87 46 Karen Spencer 69 34 459 37 Sam Bostak 26 78 56 64 Tommy Chan 36 4 86 45 Sara Thompson 49 5 44 6 Kim Jones 20 5 34 80 Janet Smith 34 6 4 66 JaeHo Lee 90 54 44 44 Butch Williams 90 56 98 6 Jeff Phillips 55 67 43 66 Tammy Colsen 36 44 45 0 Ben Stern 90 34 97 66 Mala Kimbo 46 78 56 99 Dan Swathmore 23 45 667 66 Bruce Larsen 13 6 56 47 Trudy Ruskin 90 25 24 6 James Kenson 15 6 55 56 Charles Donaldson 9 6 34 5 Lewis Braun 245 67 45 5 Clarence Arrens 98 32 55 34 Jenna Hines 39 6 45 5 George Davis 7 57 55 66 Maria Lopez 24 86 58 55 Terry George 23 56 34 12
In unix/linux, space denote a new column. (It could be one space or 20 spaces.) Notice how JaeHo is not listed as Jae Ho, with a space. If we had a space (or spaces) between the name, we would not have well-structured columns.
In this first sample we are telling Linux we want to use the awk command and that we want to print out the second column of data in the students file. Obviously, this would not work had we not created a students file. Typing awk {'print $2'}
and not designating a file will do nothing.
awk '{print $2}' students
awk '{print $2}' students | sort -k 1
awk '{print $2 ", " $1 ", " $3+$4+$5+$6}' students | sort -k 3rn
If you want to see how you can use awk to loop through a list of github users and generate a list of html links, you can go a bit deeper and check out this awk example on the class blog.
Sometimes, when you make a mistake, it will still work. Which one of these is the wrong syntax? (Compare them to the above examples.)
1 awk '{print $1}' studentsvs.
2 awk {'print $1'} students
Example 1 is correct syntax for awk; example 2 is wrong, but it works. So what's going on here?
The reason why both of these will work is because awk is a weakly typed language. Weakly typed languages are more forgiving. See this article on strong and weak typing.
Learning Markdown is very easy. Spend some time here: https://www.markdowntutorial.com/
If you install this app, it will not install in your Apps folder. If you want to click on a .md file and have it open with Mark Down Edit, click on a .md file and when prompted to set up an app, navigate to the app in this directory:
c:\Users\yourusername\AppData\Local\MarkdownEdit\bin\mde.exe
Create multiple files with Curly Braces Magic