unity% more "example2" [return]Since this is a short file, there is only one screen of data. However, had it been a larger file, the file would have scrolled by on your screen one page at a time. To see the next screen, press your space bar. To see one line at a time, use your return key. You would type a "q" if you wanted to break out of a long file.
There are two other commands called tail and head that allow you to look at the first or last "n" number of lines in a file. The format for the command is tail -n filename or head-n filename; replace "n" with the number of lines you want to view. You can change the number of lines displayed by using optional parameters; by default you are shown the first or last ten lines:
unity% tail -5 filename [return] (last 5 lines) unity% head -4 filename [return] (first 4 lines)The head and tail commands are helpful if you are trying to locate a file and have several with similar names. You could look at the beginning or ending of the file and hopefully figure out which is the correct file you need.
The more command can also be used with other commands such as ls to allow you to view, one screen at a time, all the files in a directory (if you have more than one screen of files). The format would be ls -la | more. To use the more command in this manner, we first must introduce the piping command.
Let's take the ls -la example mentioned above. If we had 100 files in our directory, the files would scroll by on our screen. However, we could take the output from the ls -la command and pipe it into the more command. Then, the file listing would scroll by one screen at a time.
unity% ls -la | more [return]Another example would be to issue the "zwho" command and pipe the output to "sort" so that the users who are currently logged on to the system are listed to your screen alphabetically:
unity% zwho | sort | more [return]
unity% cat test1 file2_test [return] This is file1. This is file2. (or whatever sentence you had in these files.) unity%Notice that this command simply listed the contents of the file to the screen; it did not join them together in a more permanent sense. However, the cat command is normally used to join two files together and create a third file.
Using the ">" sign allows you to redirect the output of the cat command. This process of redirection is used frequently in unix. Because the screen is the standard input and output for a unix command, unix expects you to input information from your keyboard and it directs the output to your screen. Redirection allows you to change the standard input and output sources. In this next example, you change the output destination so that it is a file rather than the screen.
unity% cat test1 file2_test > file3 [return]If you do an ls, you will see that you have a file called file3 (the two files combined).
Another example of redirection is:
unity% ls -la > file.list [return]This example takes the output from the ls -la command and redirects it to a file called file.list rather than to the screen.
alias new_command unix_command.
On Unity, you will find that many commands have already been aliased for you
(for example, the "rm" command has been aliased to "rm -i"). Another way to use
aliases would be to set up an alias that changes you into another directory.
This would eliminate you having to "col directory_path" everytime you wanted to
access this file space. (You would place this alias in your .mycshrc file.)
For example, suppose you have access to filespace where your web documents are
located. To access this space, you enter
cd /afs/unity/project/www/ncsu/testspace
You could create an alias called "webspace" and reference the command below. Be sure to include the command in single quotes.
alias webspace 'cd /afs/unity/.....'
grep string_to_find filename;
the following example searches the "man" pages on the "mt" (mount) command for every line that contains the word "tape":
unity% man mt | grep tape [return]The grep command is also be used to search a file for a particular character string such as a "userid" or "name."
unity% fs lq . [return] Volume Name Quota Used % Used Partition users.noell 30000 20216 67% 73% unity% quota[return] Volume Name Quota Used % Used Partition users.noell 30000 20216 67% 73%In the above example, we have used 68% of our assigned disk quota. The 73% indicates partition usage, a partition being how users are grouped together on a very large disk. You need only be concerned with your quota usage (% used); the system administrators worry about the partition usage.
unity% date [return] Mon Jul 29 10:41:23 EDT 1996
Go on to next section, Customizing your environment
Return to Table of Contents