Access over 20 million homework & study documents

search

POS 420 Week 4 UNIX Worksheet Assignment

Type

Homework

Rating

Showing Page:
1/4
UNIX Worksheet 1
UNIX Worksheet
Jon Bartholf
POS420: Introduction to UNIX
October 11, 2010
David Keathly

Sign up to view the full document!

lock_open Sign Up
UNIX Worksheet 2
Provide answers to all questions in the space provided:
1. Describe the results of executing each of the following grep commands in your
home directory. (1 pt each)
a. $ grep –c ill memo
The execution of this grep command gives the count of lines in the file “memo”
that have the string “ill” occurring anywhere within them.
b. $ grep -n ill memo
The execution of this grep command outputs all the lines from the file “memo”
that have the string “ill” occurring anywhere within them, as well as prefixes each
line with its line number in the file “memo”.
2. What would the permission section of an ls -l listing for filex look like after setting
the following permissions? (1 pt each)
a. chmod 764 filex
The chmod (change mode) command allows one to alter a file’s permissions. The
changes are specified by the user with a sort of code, where ‘r means read, ‘w’
means write, and ‘x’ means execute.
For the 764 filex, the permission section would be: -rwxrw-r--
b. chmod 666 filex
For the 666 filex, the permission section would be: -rw-rw-rw-
3. Rewrite the following sequence of commands using sort as a filter: You should end
up with a single command (not command line) when you are done. You are not
allowed to use any ;’s in your answer and you may leave out any unnecessary
items. (2 pts)
$ sort roster > temp
$ lp temp
$ rm temp
$ sort roster | lpr lpr in Linux means ‘print a file’, while lprm in Linux means
‘cancel a print job. The symbol ‘|’ is the pipe mechanism
that sends the output of the command to print (lpr).

Sign up to view the full document!

lock_open Sign Up
UNIX Worksheet 3
4. Write a command, assuming your home directory, to list all files that: (1 pt each)
a. Start with the letters b or f
$ ls [bf]*
b. Start with the letters a through k
$ ls [a-k]*
c. Have a capital letter anywhere in their name
$ ls *[A-Z]*
5. What is the difference between the following commands? (1 pt)
$ cat xyz[12] / $ cat xyz[1-2]
There really is no difference between the two commands. Both commands display
the contents of file xyz1 followed by the contents of file xyz2. The range [1-2] is the
same as the range [12]. Had the question asked about xyz[02] and xyz[0-2], then the
two commands would have been different because the range [0-2] is the same as the
range [012], not the range [02].
6. What files would the following match? (1 pt)
$ ls -l file[1-20]
The above command will list the following files: file0, file1 and file 2; it will not list
all the files from file1 through file20. This is because the brackets wildcard only sees
the numbers 0-9. In order to list all the files from 1-20, the command would have to
be similar to the following:
$ ls –l file[0-9] file1[0-9] file 20

Sign up to view the full document!

lock_open Sign Up

Anonymous
I was having a hard time with this subject, and this was a great help.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4