home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / riscbsd / datafile / usd / 01_begin / u2_txt < prev    next >
Encoding:
Text File  |  1996-10-12  |  23.9 KB  |  661 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. II.  DAY-TO-DAY USE
  8.  
  9. Creating Files -- The Editor
  10.  
  11.      If  you  have to type a paper or a letter or a program,
  12. how do you get the information stored in the machine?   Most
  13. of  these tasks are done with the ``text editor'' ed.  Since
  14. ed-is thoroughly documented in  ed(1)  and  explained  in  A
  15. Tutorial  Introduction  to  the  UNIX  Text Editor, we won't
  16. spend any time here describing how to use it.  All  we  want
  17. it  for  right now is to make some files.  (A file is just a
  18. collection of information stored in the machine, a  simplis-
  19. tic but adequate definition.)
  20.  
  21.      To  create  a file called junk-with some text in it, do
  22. the following: ed junk(invokes the text editor)  a     (com-
  23. mand  to  ``ed'', to add text) now type in whatever text you
  24. want ...  .     (signals the end of adding text)  The  ``.''
  25. that signals the end of adding text must be at the beginning
  26. of a line by itself.  Don't  forget  it,  for  until  it  is
  27. typed, no other ed-commands will be recognized -- everything
  28. you type will be treated as text to be added.
  29.  
  30.      At this point you can do various editing operations  on
  31. the text you typed in, such as correcting spelling mistakes,
  32. rearranging paragraphs and  the  like.   Finally,  you  must
  33. write  the  information  you have typed into a file with the
  34. editor command w: w ed-will respond with the number of char-
  35. acters it wrote into the file junk.
  36.  
  37.      Until  the w-command, nothing is stored permanently, so
  38. if  you  hang  up  and go home the information is lost.- But
  39. after w-the information is there permanently;  you  can  re-
  40. access  it  any  time  by typing ed junk Type a q-command to
  41. quit the editor.  (If you try to quit  without  writing,  ed-
  42. will  print  a  ?- to  remind  you.  A second q-gets you out
  43. regardless.)
  44.  
  45.      Now create a second file called temp-in the  same  man-
  46. ner.  You should now have two files, junk-and temp.
  47.  
  48. What files are out there?
  49.  
  50.      The ls-(for ``list'') command lists the names (not con-
  51. tents) of any of the files that knows about.  If you type ls
  52. the  response  will  be  junk  temp which are indeed the two
  53. files just created.  The names are sorted into  alphabetical
  54. order automatically, but other variations are possible.  For
  55. example, the command ls -t causes the files to be listed  in
  56. -----------
  57. - This is not strictly true  --  if  you  hang  up
  58. while  editing,  the  data  you were working on is
  59. saved in a file called ed.hup, which you can  con-
  60. tinue with at your next session.
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                              -2-
  71.  
  72.  
  73. the  order  in  which  they  were  last changed, most recent
  74. first.  The -l-option gives a ``long'' listing: ls  -l  will
  75. produce  something  like  -rw-rw-rw-  1 bwk   41 Jul 22 2:56
  76. junk -rw-rw-rw-  1 bwk   78 Jul 22 2:57 temp  The  date  and
  77. time  are of the last change to the file.  The 41 and 78 are
  78. the number of characters (which should agree with  the  num-
  79. bers  you  got from ed).  bwk-is the owner of the file, that
  80. is, the person who created it.  The -rw-rw-rw--tells who has
  81. permission  to  read and write the file, in this case every-
  82. one.
  83.  
  84.      Options can be combined: ls--lt-gives the same thing as
  85. ls--l,  but  sorted  into time order.  You can also name the
  86. files you're interested in, and ls-will list the information
  87. about them only.  More details can be found in ls(1).
  88.  
  89.      The  use  of optional arguments that begin with a minus
  90. sign, like -t-and -lt, is a common convention for  programs.
  91. In  general,  if  a program accepts such optional arguments,
  92. they precede any filename arguments.  It is also vital  that
  93. you  separate the various arguments with spaces: ls-l-is not
  94. the same as ls---l.
  95.  
  96. Printing Files
  97.  
  98.      Now that you've got a file of text, how do you print it
  99. so people can look at it?  There are a host of programs that
  100. do that, probably more than are needed.
  101.  
  102.      One simple thing is to use the editor,  since  printing
  103. is  often  done  just before making changes anyway.  You can
  104. say ed junk 1,$p ed-will reply with the count of the charac-
  105. ters  in  junk- and  then  print  all the lines in the file.
  106. After you learn how to use the editor, you can be  selective
  107. about the parts you print.
  108.  
  109.      There  are times when it's not feasible to use the edi-
  110. tor for printing.  For example, there is a limit on how  big
  111. a file ed-can handle (several thousand lines).  Secondly, it
  112. will only print one file at a time, and sometimes  you  want
  113. to  print  several, one after another.  So here are a couple
  114. of alternatives.
  115.  
  116.      First is cat, the simplest of  all  the  printing  pro-
  117. grams.   cat- simply  prints on the terminal the contents of
  118. all the files named in a list.  Thus  cat  junk  prints  one
  119. file,  and  cat  junk temp prints two.  The files are simply
  120. concatenated (hence the name cat'') onto the terminal.
  121.  
  122.      pr-produces formatted printouts of files.  As with cat,
  123. pr- prints all the files named in a list.  The difference is
  124. that it produces headings with date, time, page  number  and
  125. file  name  at the top of each page, and extra lines to skip
  126. over the fold in the paper.  Thus, pr junk temp  will  print
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                              -3-
  137.  
  138.  
  139. junk- neatly,  then  skip to the top of a new page and print
  140. temp-neatly.
  141.  
  142.      pr-can also produce multi-column  output:  pr  -3  junk
  143. prints  junk-in 3-column format.  You can use any reasonable
  144. number in place of ``3'' and pr-will do its  best.   pr- has
  145. other capabilities as well; see pr(1).
  146.  
  147.      It  should be noted that pr-is not a formatting program
  148. in the sense of shuffling lines around and  justifying  mar-
  149. gins.   The  true  formatters  are nroff-and troff, which we
  150. will get to in the section on document preparation.
  151.  
  152.      There are also programs that print  files  on  a  high-
  153. speed  printer.   Look  in  your  manual  under opr-and lpr.
  154. Which to use depends on what equipment is attached  to  your
  155. machine.
  156.  
  157. Shuffling Files About
  158.  
  159.      Now  that  you  have  some files in the file system and
  160. some experience in printing them, you can try bigger things.
  161. For  example,  you can move a file from one place to another
  162. (which amounts to giving it a new name), like this: mv  junk
  163. precious  This  means  that  what used to be ``junk'' is now
  164. ``precious''.  If you do an ls-command  now,  you  will  get
  165. precious  temp Beware that if you move a file to another one
  166. that already exists, the already existing contents are  lost
  167. forever.
  168.  
  169.      If  you want to make a copy of a file (that is, to have
  170. two versions of something), you can use the cp- command:  cp
  171. precious  temp1 makes a duplicate copy of precious-in temp1.
  172.  
  173.      Finally, when you get  tired  of  creating  and  moving
  174. files, there is a command to remove files from the file sys-
  175. tem, called rm.  rm temp temp1 will remove both of the files
  176. named.
  177.  
  178.      You  will  get  a  warning  message if one of the named
  179. files wasn't there, but otherwise rm,  like  most  commands,
  180. does  its  work silently.  There is no prompting or chatter,
  181. and error messages are occasionally curt.  This terseness is
  182. sometimes  disconcerting to newcomers, but experienced users
  183. find it desirable.
  184.  
  185. What's in a Filename
  186.  
  187.      So far we  have  used  filenames  without  ever  saying
  188. what's  a  legal  name,  so it's time for a couple of rules.
  189. First, filenames are limited  to  14  characters,  which  is
  190. enough to be descriptive.-  Second,  although  you  can  use
  191. -----------
  192. -  In  4.2 BSD the limit was extended to 255 char-
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                              -4-
  203.  
  204.  
  205. almost  any  character  in a filename, common sense says you
  206. should stick to ones that are visible, and that  you  should
  207. probably  avoid  characters  that  might  be used with other
  208. meanings.  We have already seen, for example, that in the ls-
  209. command, ls--t-means to list in time order.  So if you had a
  210. file whose name was -t, you would have a tough time  listing
  211. it by name.  Besides the minus sign, there are other charac-
  212. ters which have special meaning.   To  avoid  pitfalls,  you
  213. would  do  well  to use only letters, numbers and the period
  214. until you're familiar with the situation.
  215.  
  216.      On to some more positive suggestions.   Suppose  you're
  217. typing a large document like a book.  Logically this divides
  218. into many small pieces, like chapters and perhaps  sections.
  219. Physically  it  must  be divided too, for ed-will not handle
  220. really big files.  Thus you should type the  document  as  a
  221. number  of  files.   You might have a separate file for each
  222. chapter, called chap1 chap2 etc...  Or, if each chapter were
  223. broken  into  several  files, you might have chap1.1 chap1.2
  224. chap1.3 ...  chap2.1 chap2.2 ...  You  can  now  tell  at  a
  225. glance where a particular file fits into the whole.
  226.  
  227.      There  are advantages to a systematic naming convention
  228. which are not obvious to  the  novice  user.   What  if  you
  229. wanted  to  print  the whole book?  You could say pr chap1.1
  230. chap1.2 chap1.3 ......  but you would get tired pretty fast,
  231. and  would  probably even make mistakes.  Fortunately, there
  232. is a shortcut.  You can say pr chap* The *-means  ``anything
  233. at  all,''  so  this translates into ``print all files whose
  234. names begin with chap'', listed in alphabetical order.
  235.  
  236.      This shorthand notation is not a  property  of  the  pr-
  237. command,  by  the  way.  It is system-wide, a service of the
  238. program that interprets  commands  (the  ``shell,''  sh(1)).
  239. Using  that  fact,  you can see how to list the names of the
  240. files in the book: ls chap* produces chap1.1 chap1.2 chap1.3
  241. ...  The *-is not limited to the last position in a filename
  242. -- it can be anywhere and can occur several times.  Thus  rm
  243. *junk* *temp* removes all files that contain junk-or temp-as
  244. any part of their name.  As a  special  case,  *- by  itself
  245. matches  every  filename,  so  pr  *  prints  all your files
  246. (alphabetical order), and rm * removes all files.  (You  had
  247. better be sure that's what you wanted to say!)
  248.  
  249.      The  *- is not the only pattern-matching feature avail-
  250. able.  Suppose you want to print only chapters 1  through  4
  251. and  9.  Then you can say pr chap[12349]* The [...]-means to
  252. match any of the characters inside the brackets.  A range of
  253. consecutive letters or digits can be abbreviated, so you can
  254. also do this with pr chap[1-49]* Letters can  also  be  used
  255. within  brackets: [a-z]-matches any character in the range a-
  256. through z.
  257. -----------
  258. acters.
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                              -5-
  269.  
  270.  
  271.      The ?-pattern matches any single  character,  so  ls  ?
  272. lists all files which have single-character names, and ls -l
  273. chap?.1 lists information about the first file of each chap-
  274. ter chap1.1, chap2.1, etc.).
  275.  
  276.      Of  these niceties, *-is certainly the most useful, and
  277. you should get used to it.  The others are frills, but worth
  278. knowing.
  279.  
  280.      If you should ever have to turn off the special meaning
  281. of *, ?, etc., enclose the entire argument in single quotes,
  282. as in ls '?' We'll see some more examples of this shortly.
  283.  
  284. What's in a Filename, Continued
  285.  
  286.      When  you first made that file called junk, how did the
  287. system know that there wasn't another junk- somewhere  else,
  288. especially since the person in the next office is also read-
  289. ing this tutorial?  The answer is that generally  each  user
  290. has  a  private which contains only the files that belong to
  291. him.  When you  log  in,  you  are  ``in''  your  directory.
  292. Unless  you take special action, when you create a new file,
  293. it is made in the directory that you are currently in;  this
  294. is most often your own directory, and thus the file is unre-
  295. lated to any other file of the same name that might exist in
  296. someone else's directory.
  297.  
  298.      The  set of all files is organized into a (usually big)
  299. tree, with your files  located  several  branches  into  the
  300. tree.   It is possible for you to ``walk'' around this tree,
  301. and to find any file in the system, by starting at the  root
  302. of  the  tree  and walking along the proper set of branches.
  303. Conversely, you can start where you are and walk toward  the
  304. root.
  305.  
  306.      Let's  try  the  latter  first.  The basic tools is the
  307. command pwd-(``print working directory''), which prints  the
  308. name of the directory you are currently in.
  309.  
  310.      Although  the details will vary according to the system
  311. you are on, if you give the command pwd, it will print some-
  312. thing  like  /usr/your-name This says that you are currently
  313. in the directory your-name, which is in turn in  the  direc-
  314. tory  /usr, which is in turn in the root directory called by
  315. convention just /.  (Even if it's not called  /usr- on  your
  316. system,  you  will get something analogous.  Make the corre-
  317. sponding mental adjustment and read on.)
  318.  
  319.      If you  now  type  ls  /usr/your-name  you  should  get
  320. exactly  the same list of file names as you get from a plain
  321. ls: with no arguments, ls-lists the contents of the  current
  322. directory;  given the name of a directory, it lists the con-
  323. tents of that directory.
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                              -6-
  335.  
  336.  
  337.      Next, try ls /usr This should print a  long  series  of
  338. names,  among  which  is  your own login name your-name.  On
  339. many systems, usr-is a directory that contains the  directo-
  340. ries of all the normal users of the system, like you.
  341.  
  342.      The  next step is to try ls / You should get a response
  343. something like this (although again the details may be  dif-
  344. ferent): bin dev etc lib tmp usr This is a collection of the
  345. basic directories of files that the system knows  about;  we
  346. are at the root of the tree.
  347.  
  348.      Now  try  cat  /usr/your-name/junk  (if  junk- is still
  349. around in your directory).  The name /usr/your-name/junk  is
  350. called  the  pathname-of the file that you normally think of
  351. as ``junk''.  ``Pathname'' has an obvious meaning: it repre-
  352. sents  the full name of the path you have to follow from the
  353. root through the tree of directories to get to a  particular
  354. file.   It  is  a universal rule in the system that anywhere
  355. you can use an ordinary filename, you can use a pathname.
  356.  
  357.      Here is a picture which may make this clearer:
  358.                            (root)
  359.                            / | \
  360.                           /  |  \
  361.                          /   |   \
  362.                 bin    etc    usr    dev   tmp
  363.            / | \   / | \   / | \   / | \   / | \
  364.                           /  |  \
  365.                          /   |   \
  366.                       adam  eve   mary
  367.                   /        /   \        \
  368.                            /     \       junk
  369.                          junk temp
  370.  
  371. Notice that Mary's junk-is unrelated to Eve's.
  372.  
  373.      This isn't too exciting if all the  files  of  interest
  374. are in your own directory, but if you work with someone else
  375. or  on  several  projects  concurrently,  it  becomes  handy
  376. indeed.   For  example,  your friends can print your book by
  377. saying pr /usr/your-name/chap* Similarly, you can  find  out
  378. what files your neighbor has by saying ls /usr/neighbor-name
  379. or  make  your  own  copy  of  one  of  his  files   by   cp
  380. /usr/your-neighbor/his-file yourfile
  381.  
  382.      If  your neighbor doesn't want you poking around in his
  383. files, or vice versa, privacy can be  arranged.   Each  file
  384. and  directory  has  read-write-execute  permissions for the
  385. owner, a group, and everyone else, which can be set to  con-
  386. trol access.  See ls(1) and chmod(1) for details.  As a mat-
  387. ter of observed fact, most users most of the time find open-
  388. ness of more benefit than privacy.
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                              -7-
  401.  
  402.  
  403.      As  a  final  experiment  with  pathnames,  try ls /bin
  404. /usr/bin Do some of the names look familiar?  When you run a
  405. program,  by typing its name after the prompt character, the
  406. system simply looks for a file of that  name.   It  normally
  407. looks  first  in  your directory (where it typically doesn't
  408. find it), then in /bin-and finally in  /usr/bin.   There  is
  409. nothing  magic  about  commands  like cat-or ls, except that
  410. they have been collected into a couple of places to be  easy
  411. to find and administer.
  412.  
  413.      What  if you work regularly with someone else on common
  414. information in his directory?  You could just log in as your
  415. friend  each time you want to, but you can also say ``I want
  416. to work on his files instead of my own''.  This is  done  by
  417. changing  the  directory  that  you  are  currently  in:  cd
  418. /usr/your-friend (On some systems,  cd- is  spelled  chdir.)
  419. Now  when you use a filename in something like cat-or pr, it
  420. refers to the file in  your  friend's  directory.   Changing
  421. directories doesn't affect any permissions associated with a
  422. file -- if you couldn't access a file from your  own  direc-
  423. tory,  changing  to another directory won't alter that fact.
  424. Of course, if you forget what directory you're in, type  pwd
  425. to find out.
  426.  
  427.      It  is  usually convenient to arrange your own files so
  428. that all the files related to one thing are in  a  directory
  429. separate  from  other projects.  For example, when you write
  430. your book, you might want to keep all the text in  a  direc-
  431. tory called book.  So make one with mkdir book then go to it
  432. with cd book then start typing chapters.  The  book  is  now
  433. found  in  (presumably)  /usr/your-name/book  To  remove the
  434. directory book, type rm book/* rmdir book The first  command
  435. removes all files from the directory; the second removes the
  436. empty directory.
  437.  
  438.      You can go up one level in the tree of files by  saying
  439. cd  ..  ..'' is the name of the parent of whatever directory
  440. you are currently in.  For completeness, .'' is an alternate
  441. name for the directory you are in.
  442.  
  443. Using Files instead of the Terminal
  444.  
  445.      Most of the commands we have seen so far produce output
  446. on the terminal; some, like  the  editor,  also  take  their
  447. input  from  the  terminal.  It is universal in systems that
  448. the terminal can be replaced by a file for either or both of
  449. input  and output.  As one example, ls makes a list of files
  450. on your terminal.  But if you say ls  >filelist  a  list  of
  451. your  files  will be placed in the file filelist-(which will
  452. be created if it doesn't already exist, or overwritten if it
  453. does).  The symbol >-means ``put the output on the following
  454. file, rather than on the terminal.''  Nothing is produced on
  455. the terminal.  As another example, you could combine several
  456. files into one by capturing the output of cat-in a file: cat
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                              -8-
  467.  
  468.  
  469. f1 f2 f3 >temp
  470.  
  471.      The  symbol  >>- operates very much like >-does, except
  472. that it means ``add to the end of.''  That is, cat f1 f2  f3
  473. >>temp  means  to  concatenate  f1,  f2-and f3-to the end of
  474. whatever is already in  temp,  instead  of  overwriting  the
  475. existing  contents.   As  with  >, if temp-doesn't exist, it
  476. will be created for you.
  477.  
  478.      In a similar way, the symbol <-means to take the  input
  479. for  a  program from the following file, instead of from the
  480. terminal.  Thus, you could make up a script of commonly used
  481. editing  commands  and  put  them into a file called script.
  482. Then you can run the script on a  file  by  saying  ed  file
  483. <script As another example, you can use ed-to prepare a let-
  484. ter in file let, then send it to several  people  with  mail
  485. adam eve mary joe <let
  486.  
  487. Pipes
  488.  
  489.      One  of  the  novel  contributions of the system is the
  490. idea of a pipe.  A pipe is simply a way to connect the  out-
  491. put  of  one program to the input of another program, so the
  492. two run as a sequence of processes -- a pipeline.
  493.  
  494.      For example, pr f g h will print the files f, g, and h,
  495. beginning  each  on  a  new page.  Suppose you want them run
  496. together instead.  You could say cat f g h >temp pr <temp rm
  497. temp  but this is more work than necessary.  Clearly what we
  498. want is to take the output of cat- and  connect  it  to  the
  499. input  of pr.  So let us use a pipe: cat f g h | pr The ver-
  500. tical bar |-means to take the output from cat,  which  would
  501. normally have gone to the terminal, and put it into pr-to be
  502. neatly formatted.
  503.  
  504.      There are many other examples of pipes.   For  example,
  505. ls  |  pr  -3  prints a list of your files in three columns.
  506. The program wc-counts the number of lines, words and charac-
  507. ters  in its input, and as we saw earlier, who-prints a list
  508. of currently-logged on people, one per line.  Thus who |  wc
  509. tells  how many people are logged on.  And of course ls | wc
  510. counts your files.
  511.  
  512.      Any program that reads from the terminal can read  from
  513. a  pipe instead; any program that writes on the terminal can
  514. drive a pipe.  You can have as many elements in  a  pipeline
  515. as you wish.
  516.  
  517.      Many  programs are written so that they will take their
  518. input from one or more files if file arguments are given; if
  519. no arguments are given they will read from the terminal, and
  520. thus can be used in pipelines.  pr-is one example: pr -3 a b
  521. c prints files a, b-and c-in order in three columns.  But in
  522. cat a b c | pr -3 pr-prints the information coming down  the
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                              -9-
  533.  
  534.  
  535. pipeline, still in three columns.
  536.  
  537. The Shell
  538.  
  539.      We  have already mentioned once or twice the mysterious
  540. ``shell,'' which is in fact sh(1).- The shell is the program
  541. that interprets what you type as commands and arguments.  It
  542. also  looks  after  translating *, etc., into lists of file-
  543. names, and <, >, and |-into  changes  of  input  and  output
  544. streams.
  545.  
  546.      The shell has other capabilities too.  For example, you
  547. can run two programs with one command line by separating the
  548. commands  with  a  semicolon; the shell recognizes the semi-
  549. colon and breaks the line into two commands.  Thus date; who
  550. does both commands before returning with a prompt character.
  551.  
  552.      You can also have more than one program running  simul-
  553. taneously  if you wish.  For example, if you are doing some-
  554. thing time-consuming, like the editor script of  an  earlier
  555. section,  and  you don't want to wait around for the results
  556. before starting something else, you can say ed file  <script
  557. &  The  ampersand  at the end of a command line says ``start
  558. this command running, then take further  commands  from  the
  559. terminal  immediately,''  that is, don't wait for it to com-
  560. plete.  Thus the script will begin, but you can do something
  561. else  at  the same time.  Of course, to keep the output from
  562. interfering with what you're doing on the terminal, it would
  563. be  better  to say ed file <script >script.out & which saves
  564. the output lines in a file called script.out.
  565.  
  566.      When you initiate a command with &, the system  replies
  567. with  a  number  called the process number, which identifies
  568. the command in case you later want to stop it.  If  you  do,
  569. you  can  say  kill process-number If you forget the process
  570. number, the command ps-will tell you  about  everything  you
  571. have  running.   (If you are desperate, kill-0-will kill all
  572. your processes.)  And if you're curious about other  people,
  573. ps-a- will  tell  you  about all programs that are currently
  574. running.
  575.  
  576.      You can say  (command-1;  command-2;  command-3)  &  to
  577. start  three  commands in the background, or you can start a
  578. background pipeline with command-1 | command-2 &
  579.  
  580.      Just as you can tell the editor or some similar program
  581. to  take its input from a file instead of from the terminal,
  582. you can tell the shell to read a file to get commands.  (Why
  583. not?  The  shell,  after  all,  is  just a program, albeit a
  584. clever one.)  For instance, suppose you want to set tabs  on
  585. your terminal, and find out the date and who's on the system
  586. -----------
  587. - On Berkeley Unix systems, the  usual  shell  for
  588. interactive use is the c shell, csh(1).-
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.                             -10-
  599.  
  600.  
  601. every time you log in.  Then you can put the three necessary
  602. commands  tabs,  date,  who)  into  a  file,  let's  call it
  603. startup, and then run it with sh startup This  says  to  run
  604. the  shell with the file startup-as input.  The effect is as
  605. if you had typed the contents of startup-on the terminal.
  606.  
  607.      If this is to be a regular thing, you can eliminate the
  608. need  to  type sh: simply type, once only, the command chmod
  609. +x startup and thereafter you need only say startup  to  run
  610. the  sequence  of  commands.  The chmod(1) command marks the
  611. file executable; the shell recognizes this and runs it as  a
  612. sequence of commands.
  613.  
  614.      If you want startup-to run automatically every time you
  615. log in,  create  a  file  in  your  login  directory  called
  616. .profile,  and place in it the line startup.  When the shell
  617. first gains control when  you  log  in,  it  looks  for  the
  618. .profile- file  and  does whatever commands it finds in it.-
  619. We'll get back to the shell in the section on programming.
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653. -----------
  654. - The c shell instead reads a file called .login-
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.