Assignment 1b
Created Friday 10 February 2017
Continuing our tour of bash.
Lets get a bigger file; we'll use a command I covered briegly wget. First just try typing "wget" on a line by itself. That will not actually "do" anything. Next type "man wget."
6) In a sentence or two, tell me what "wget" is/does.
Okay, next, type the following:
wget "http://www.gutenberg.org/cache/epub/23/pg23.txt"
to get a file called pg23.txt.
Once it's finished, first try
cat pg23.txt
Next, try
less pg23.txt
(hit q to get out of it)
- What is the difference between less and cat?
Let's rename this file to something slightly more descriptive, but still short for us. How about fd.txt?
type:
mv pg23.txt fd.txt
Okay, lets use some basic commands to play around with this file a bit. A command we did see for a second in class is "sort"
Try typing:
sort fd.txt
9(a). Before doing anything else, describe what just happened.
Now, type
less fd.txt
9(b). In your own words — is this a surprising result? If you would like to augment or modify your answer to 9a at this point, please feel free to do so here. (you may not, but I'd like to know if you do, so thats why I'm phrasing the question this way)
What if we actually wanted to "keep" the weird thing that came out when we did the sort command? We have to use a "redirect," to redirect the output of a command to something other than stdout (Standard Output)? Try this:
sort fd.txt > fdweird.txt
Now we have two files. Lets make some backups of them. Do:
cp fd.txt fd.bak cp fdweird.txt fdweird.bak
Okay. Now: do that first command AGAIN:
sort fd.txt > fdweird.txt
10a What happened?
Finally, do this slightly different command:
sort fd.txt >> fdweird.txt
10b. Review fdweird.txt (or perhaps try another ls -a) — what happened here?
10c. What is the difference between > and >>?
Another command we looked at is the sort command, which alphabetizes things; but lets try something a little different: As above, make a file that looks like the following. Name it numbers.txt
34 78 1001 12 30 4084
(each of these numbers, on its own line, with nothing else)
Next type
sort numbers.txt
11. What happened? Does this look right?
If it doesn't look right, fix it. That is -
12. Give me the command in the format that does this "correctly."
13.How did you figure it out?
Backlinks: FSU Courses:LIS5364