Unix commands-3
mkdir
Use this command to create a directory.
% mkdir essaysTo get "into" this directory, do
% cd essaysTo see what files are in essays, do this:
% lsThere shouldn't be any files there yet, since you just made it. To create files, see cat or emacs. more
More is a command used to read text files. For example, we could do this: % more poemsThe effect of this to let you read the file "poems ". It probably will not fit in one screen, so you need to know how to "turn pages". Here are the basic commands:- q --- quit more
- spacebar --- read next page
- return key --- read next line
- b --- go back one page
mv
Use this command to change the name of file and directories. % mv foo foobarThe file that was named foo is now named foobar ncftp
Use ncftp for anonymous ftp --- that means you don't have to have a password. % ncftp ftp.fubar.net Connected to ftp.fubar.net > get jokes.txtThe file jokes.txt is downloaded from the machine ftp.fubar.net.This is a moderately intelligent print command.
% print foo % print notes.ps % print manuscript.dviIn each case print does the right thing, regardless of whether the file is a text file (like foo ), a postcript file (like notes.ps, or a dvi file (likemanuscript.dvi. In these examples the file is printed on the default printer. To see what this is, do % printand read the message displayed. To print on a specific printer, do this:
% print foo jwb321 % print notes.ps jwb321 % print manuscript.dvi jwb321To change the default printer, do this:
% setenv PRINTER jwb321pwd
Use this command to find out what directory you are working in.
% pwd/u/ma/jeremy
% cd homework % pwd/u/ma/jeremy/homework
% lsassign-1 assign-2 assign-3
% cd % pwd/u/ma/jeremy
%Jeremy began by working in his "home" directory. Then he cd 'd into his homework subdirectory. Cd means " change directory". He used pwd to check to make sure he was in the right place, then used ls to see if all his homework files were there. (They were). Then he cd'd back to his home directory.rm
Use rm to remove files from your directory.
% rm foo remove foo? y % rm letter* remove letter1? y remove letter2? y remove letter3? n %The first command removed a single file. The second command was intended to remove all files beginning with the string "letter." However, our user (Jeremy?) decided not to remove letter3.rmdir
Use this command to remove a directory. For example, to remove a directory called "essays", do this: % rmdir essaysA directory must be empty before it can be removed. To empty a directory, use rm. rsh
Use this command if you want to work on a computer different from the one you are currently working on. One reason to do this is that the remote machine might be faster. For example, the command % rsh solitudeconnects you to the machine solitude. This is one of our public workstations and is fairly fast.See also: telnet
setenv
% echo $PRINTER labprinter % setenv PRINTER myprinter % echo $PRINTER myprintersort
Use this commmand to sort a file. For example, suppose we have a filedict with contents
red rojo
green verde
blue azul
white blanco
black negro
Then we can do this:
% sort dict black negro blue azul green verde red rojo white blancoHere the output of sort went to the screen. To store the output in file we do this:
% sort dict >dict.sorted tail
Use this command to look at the tail of a file. For example, % head essay.001displays the last 10 lines of the file essay.001 To see a specific number of lines, do this: % head -20 essay.001This displays the last 20 lines of the file.
tar
Use create compressed archives of directories and files, and also to extract directories and files from an archive. Example: % tar -tvzf foo.tar.gzdisplays the file names in the compressed archive foo.tar.gz while % tar -xvzf foo.tar.gzextracts the files.
telnet
Use this command to log in to another machine from the machine you are currently working on. For example, to log in to the machine "solitude", do this: % telnet solitudeSee also: rsh. wc
Use this command to count the number of characters, words, and lines in a file. Suppose, for example, that we have a file dict with contentsred rojo
green verde
blue azul
white blanco
black negro
Then we can do this
% wc dict5 10 56 tmpThis shows that dict has 5 lines, 10 words, and 56 characters.
The word count command has several options, as illustrated below:
% wc -l dict 5 tmp % wc -w dict 10 tmp % wc -c dict56 tmp
No comments:
Post a Comment