schmoe and Schmoe are different.
Unlike MS-DOS, UNIX does not require filenames to have a three-letter
"extension", as in MYPROG.EXE. Nevertheless, many kinds of
files customarily do have certain standard suffixes. Some of the ones
that you are likely to encounter are:
.txt.f.c.cc.o.Zcompress command (binary file)
.gzgzip
command (binary file)
.tar.psEvery file and directory on a UNIX system can be specified completely by listing the chain of directories and sub-directories that contains it, separated by slashes (/). This is called an absolute pathname. Examples:
/ /u1 u1, in the root directory
/u1/schmoe schmoe, in subdirectory u1 of the root directory
/u1/schmoe/program.f program.f in the subdirectory schmoe of the
subdirectory u1 of the root directory
/u1/schmoe, you can use
program.f /u1/schmoe/program.f
cs301/hw2.cc /u1/schmoe/cs301/hw2.cc
ls command at the $ prompt, you
will see a list of the files and subdirectories in your current
directory. Think of ls as meaning
"list." You can tell the $ ls $ ls -a $ ls -l $ ls -al $ ls -a -l
ls listing shows just the names of the files,
packed several per line. The ls -a listing shows one line of
information for each file. Each line looks something like this:
-rw------- 1 rossa users 7469 Aug 25 07:53 myprog.c
^^^^^^^^^^ ^^^^^ ^^^^^ ^^^^ ^^^^^^^^^^^^ ^^^^^^^^
1 2 3 4 5 6
The different items have the following meanings:
- d ls -l with a filename. For example, the following command
will give you the information shown above, for that file only:
$ ls -l myprog.c
To do this for a group of files with similar names, you can use a
"wildcard" in the file name. An asterisk
(*) matches any sequence of characters; a question mark
(?) matches any single character. For example:
*.txtcoldfusion.txt,
junk.txt, etc.
cold*coldfusion.txt,
cold-medicine, etc.
data.?xdata.ax and
data.bx, but not data.tax .
cd
command ("change directory").
$ cd cs301 cs301.
$ cd .. $ cd /local/classes/cs301 $ cd classes/cs301 $ cd ../cs301 cs301.
pwd command ("print working directory").
$ pwd mkdir command ("make directory").
$ mkdir cs301 cs301 in your current directory.
vi.
For information on vi, see the vi notes.
You can also create the file on a PC and ftp it over to the UNIX system.
vi. You may need to be careful
that you don't accidentally change the file. A better way is to use view,
which has the vi positioning commands but cannot write files.A safer way is to use one of the UNIX file-viewing commands:
$ more filename h to see other options.
$ page filename
$ cp myprog.cc myprog.cc.backup
This creates a copy of the file myprog.cc, and puts it in myprog.cc.backup.
$ mv myprog.cc.backup myprog.cc
This renames myprog.cc.backup back to myprog.cc. Warning! If you already have a file with the name that you're trying to change to (myprog.cc in this case), Unix will delete the "old" file and not warn you about it! So it's usually a good idea to use ls to check first, before you rename a file, to see if you already have one with the same name.
$ rm filename $ rm file1 file2 file3
$ rm *.f .f, in your current directory, using a wildcard.
* in an
rm command, because * all by itself means "all
non-dot files in your current directory." If you type rm *
.f (which differs only by a blank space from the last example
above!), you're saying "remove all the non-dot files, then remove the
file .f."
A safer way to use rm with wildcards is to include the
-i option:
$ rm -i *.f
This will ask (inquire) individually about each file which matches the wildcard, giving you a chance to rescue some of them from oblivion.
$ rmdir dirname $ rm -r dirname