User Tools

Site Tools


Sidebar

projects

pct0 (bonus; due 20230823)
wcp1 (due 20230823)
abc0 (due 20230830)
pct1 (bonus; due 20230830)
pct2 (due 20230830)
wcp2 (due 20230830)
dac0 (due 20230906)
pct3 (bonus; due 20230906)
wcp3 (due 20230906)
gtf0 (due 20230913)
pct4 (due 20230913)
wcp4 (due 20230913)
pct5 (bonus; due 20230920)
tpb0 (due 20230920)
wcp5 (due 20230920)
gfo0 (due 20230927)
pct6 (due 20230927)
tpb1 (due 20230927)
wcp6 (due 20230927)
pct7 (bonus; due 20231004)
tpb2 (due 20231004)
wcp7 (due 20231004)
bwp1 (bonus; due 20231018)
pct8 (due 20231018)
usr0 (due 20231018)
wcp8 (due 20231018)
fwg0 (due 20231025)
pct9 (bonus; due 20231025)
wcp9 (due 20231025)
gfo1 (due 20231101)
pctA (due 20231101)
upf0 (due 20231101)
wcpA (due 20231101)
pctB (bonus; due 20231108)
usf0 (due 20231108)
wcpB (due 20231108)
ldg0 (due 20231115)
pctC (due 20231115)
wcpC (due 20231115)
bwp2 (bonus; due 20231129)
pctD (bonus; due 20231129)
wcpD (bonus; due 20231129)
gfo2 (due 20231206)
pctE (bonus; due 20231206)
wcpE (bonus; due 20231206)
EoCE (due 20231214)
haas:fall2023:unix:cs:cs2


Corning Community College


UNIX/Linux Fundamentals



Case Study 0x2: Unconventional Naming

~~TOC~~

Objective

To see an importance in holding certain conventions, and how to deal with situations that deviate in some way.

Background

With the increasing popularity of “Personal Computers” and “File Sharing Services”, there has been a surplus of inappropriately named files. Characters like the space, while a valid character to use, can make for some interesting command-line issues as you will soon encounter.

As this behavior isn't likely to go away, it is important to know how to deal with such files on a UNIX system.

Copy the badname.tgz file from the naming/ subdirectory of the UNIX public directory into your home directory and extract all the files. They will go into a badname/ directory relative to your current directory.

There are three subdirectories created under the badname directory: example/, exercise/, and bonus/

Change into the various directories and list the files. Take a look at the names, and try to figure out what they are. Try and see if you can view their contents by conventional means (by manual typing.. no shortcuts :) )

For example, here are some of the files you may encounter:

Try to view: look at me.text
Try to rename: change my name.file
Try to remove: ??? can you delete me ???.abc
Try to compress: compress this file.data

More likely than not, you will experience some problems dealing with these files under normal means. A real aggravation.

What's the problem? The UNIX shell, like many other command-line oriented environments, uses the space as an argument separator. So when you try to cat, mv, gzip, or rm these troublesome files, the shell will try to interpret the single long file name as separate individual names.

look at me.text is the actual name of the file, but when given as an argument to cat, it will try to separately open the files:

  • look
  • at
  • me.text

There are ways to deal with such files. (Thank goodness!)

In the UNIX shell, there are several special characters that can be used on the command line to accomodate these awkward conditions. These characters harbor special powers that can be used to change the behavior of items typed. Some of these characters are displayed in the following table:

Character Behavior
* wildcard for zero or more of “any” character
\ escape the following character
“ ” (or ' ') quote the enclosed characters

Therefore, to take control of look at me.text with the cat utility, change into the example/ subdirectory and do the following:

lab46:~$ cd badname/example
lab46:~/badname/example$ cat look*

or…

lab46:~/badname/example$ cat "look at me.text"

or…

lab46:~/badname/example$ cat look\ at\ me.text

In each case you are properly instructing the shell how to display the file.

You should now have the ability to handle these malformed or inappropriately named files. So the best way to familiarize yourself with these new capabilities is to play with them.

Exercise

Using the three special characters outlined above, I'd like you to perform the appropriate operations on the files in the exercise/ directory. (In most cases, being able to view their contents will be sufficient).

Change into the exercise/ subdirectory and have fun.

1. Using the * wildcard:
a.Choose at least 3 files and attempt to gain access to their contents.
b.Submit the successful command-lines and detail and interesting observations you made.
2. Using the \ escape character:
a.Choose at least 3 files and attempt to gain access to their contents.
b.Submit the successful command-lines and detail and interesting observations you made.
3. Using the shell quoting facilities:
a.Attempt to do the same for the remainder of the files.
b.Show me the successful command-lines, and explain any observations you made.

NOTE: You may need to combine some of these special characters to accomplish the task. My intention is for you to give all of them a fair trial, not just rely on one. And do not use shortcuts such as “Tab Completions”. They are useful outside of the assignment, but here I want you to show me you understand the logic behind it.

4. Do the following:
a.Change into the challenge/ subdirectory.
b.Remove the file (and ONLY the file) located there.
c.Tell me how you were able to accomplish this.

NOTE: For the challenge, do NOT use the -r argument to rm(1).

Conclusions

This assignment has activities which you should tend to- document/summarize knowledge learned on your Opus.

As always, the class mailing list and class IRC channel are available for assistance, but not answers.

haas/fall2023/unix/cs/cs2.txt · Last modified: 2013/09/17 06:40 by 127.0.0.1