home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / unix_new.txt < prev    next >
Encoding:
Internet Message Format  |  2003-06-11  |  29.9 KB

  1. From: sahayman@iuvax.cs.indiana.edu (Steve Hayman)
  2. Newsgroups: comp.unix.questions,comp.unix.wizards
  3. Subject: Frequently Asked Questions about Unix - with Answers [Monthly posting]
  4. Message-ID: <FAQ2.9@iuvax.cs.indiana.edu>
  5. Date: 1 Dec 89 19:54:14 GMT
  6. Expires: 1 Jan 90 05:00:00 GMT
  7. Followup-To: comp.unix.questions
  8. Organization: Computer Science Department, Indiana University
  9. Lines: 865
  10. Supersedes: <FAQ2.8@iuvax.cs.indiana.edu>
  11.  
  12. [Last changed: $Date: 89/12/01 14:50:10 $ by $Author: sahayman $]
  13.  
  14. This article contains the answers to some Frequently Asked Questions
  15. often seen in comp.unix.questions and comp.unix.wizards.  Please don't
  16. ask these questions again, they've been answered plenty of times
  17. already - and please don't flame someone just because they may not have
  18. read this particular posting.  Thank you.
  19.  
  20. This article includes answers to:
  21.  
  22.  
  23.     How do I remove a file whose name begins with a "-" ?
  24.     How do I remove a file with funny characters in the filename ?
  25.     How do I get a recursive directory listing?
  26.     How do I get the current directory into my prompt?
  27.     How do I read characters from a terminal without requiring the user
  28.         to hit RETURN?
  29.     How do I read characters from the terminal in a shell script?
  30.     How do I check to see if there are characters to be read without
  31.         actually reading?
  32.     How do I find the name of an open file?
  33.     How do I rename "*.foo" to "*.bar", or change file names to lowercase?
  34.     Why do I get [some strange error message] when I "rsh host command" ?
  35.     How do I find out the creation time of a file?
  36.     How do I use "rsh" without having the rsh hang around
  37.         until the remote command has completed?
  38.     How do I truncate a file?
  39.     How do I {set an environment variable, change directory} inside a
  40.         shell script and have that change affect my current shell?
  41.     Why doesn't find's "{}" symbol do what I want?
  42.     How do I redirect stdout and stderr separately in csh?
  43.     How do I set the permissions on a symbolic link?
  44.     What does {awk,grep,fgrep,egrep,biff,cat,gecos,nroff,troff,tee,bss}
  45.         stand for?
  46.     How do I pronounce "vi" , or "!", or "/*", or ...?
  47.  
  48.  
  49.  
  50. While these are all legitimate questions, they seem to crop up in
  51. comp.unix.questions on an annual basis, usually followed by plenty
  52. of replies (only some of which are correct) and then a period of
  53. griping about how the same questions keep coming up.  You may also like
  54. to read the monthly article "Answers to Frequently Asked Questions"
  55. in the newsgroup "news.announce.newusers", which will tell you what
  56. "UNIX" stands for.
  57.  
  58. With the variety of Unix systems in the world, it's hard to guarantee
  59. that these answers will work everywhere.  Read your local manual pages
  60. before trying anything suggested here.  If you have suggestions or
  61. corrections for any of these answers, please send them to to
  62. sahayman@iuvax.cs.indiana.edu or iuvax!sahayman.
  63.  
  64. 1)  How do I remove a file whose name begins with a "-" ?
  65.  
  66.     Figure out some way to name the file so that it doesn't
  67.     begin with a dash.  The simplest answer is to use   
  68.  
  69.         rm ./-filename
  70.  
  71.     (assuming "-filename" is in the current directory, of course.)
  72.     This method of avoiding the interpretation of the "-" works
  73.     with other commands too.
  74.  
  75.     Many commands, particularly those that have been written to use
  76.     the "getopt(3)" argument parsing routine, accept a "--" argument
  77.     which means "this is the last option, anything after this is not
  78.     an option", so your version of rm might handle "rm -- -filename".
  79.     Some versions of rm that don't use getopt() treat a single "-"
  80.     in the same way, so you can also try "rm - -filename".
  81.     
  82. 2)  How do I remove a file with funny characters in the filename ?
  83.  
  84.     The  classic answers are
  85.  
  86.     rm -i some*pattern*that*matches*only*the*file*you*want
  87.  
  88.     which asks you whether you want to remove each file matching
  89.     the indicated pattern;  depending on your shell, this may
  90.     not work if the filename has a character with the 8th bit set
  91.     (the shell may strip that off);
  92.     
  93.     and
  94.  
  95.     rm -ri .
  96.  
  97.     which asks you whether to remove each file in the directory,
  98.     answer "y" to the problem file and "n" to everything else.,
  99.     and which, unfortunately, doesn't work with many versions of rm;
  100.     (always take a deep breath and think about what you're doing
  101.     and double check what you typed when you use rm's "-r" flag)
  102.  
  103.     and
  104.  
  105.     find . -type f ... -ok rm '{}' \;
  106.  
  107.     where "..." is a group of predicates that uniquely identify the
  108.     file.  One possibility is to figure out the inode number
  109.     of the problem file (use "ls -i .") and then use
  110.  
  111.     find . -inum 12345 -ok rm '{}' \;
  112.     
  113.     or
  114.     find . -inum 12345 -ok mv '{}' new-file-name \;
  115.     
  116.     
  117.     "-ok" is a safety check - it will prompt you for confirmation of the
  118.     command it's about to execute.  You can use "-exec" instead to avoid
  119.     the prompting, if you want to live dangerously, or if you suspect
  120.     that the filename may contain a funny character sequence that will mess
  121.     up your screen when printed.
  122.  
  123.     If none of these work, find your system manager.
  124.  
  125. 3)  How do I get a recursive directory listing?
  126.  
  127.     One of the following may do what you want:
  128.  
  129.     ls -R             (not all versions of "ls" have -R)
  130.     find . -print        (should work everywhere)
  131.     du -a .            (shows you both the name and size)
  132.     
  133.     If you're looking for a wildcard pattern that will match
  134.     all ".c" files in this directory and below, you won't find one,
  135.     but you can use
  136.  
  137.     % some-command `find . -name '*.c' -print`
  138.  
  139.     "find" is a powerful program.  Learn about it.
  140.  
  141. 4)  How do I get the current directory into my prompt?
  142.  
  143.     It depends which shell you are using.  It's easy with some shells,
  144.     hard or impossible with others.
  145.     
  146.     C Shell (csh):
  147.     Put this in your .cshrc - customize the prompt variable
  148.     the way you want.
  149.  
  150.         alias setprompt 'set prompt="${cwd}% "'
  151.         setprompt        # to set the initial prompt
  152.         alias cd 'chdir \!* && setprompt'
  153.     
  154.     If you use pushd and popd, you'll also need
  155.  
  156.         alias pushd 'pushd \!* && setprompt'
  157.         alias popd  'popd  \!* && setprompt'
  158.  
  159.     Some C shells don't keep a $cwd variable - you can use
  160.     `pwd` instead.
  161.  
  162.     If you just want the last component of the current directory
  163.     in your prompt ("mail% " instead of "/usr/spool/mail% ")
  164.     you can use
  165.  
  166.         alias setprompt 'set prompt="$cwd:t% "'
  167.  
  168.     
  169.     Some older csh's get the meaning of && and || reversed.
  170.     Try doing:
  171.  
  172.         false && echo bug
  173.  
  174.     If it prints "bug", you need to switch && and || (and get
  175.     a better version of csh.)
  176.  
  177.  
  178.     Bourne Shell (sh):
  179.  
  180.     If you have a newer version of the Bourne Shell (SVR2 or newer)
  181.     you can use a shell function to make your own command, "xcd" say:
  182.  
  183.         xcd() { cd $* ; PS1="`pwd` $ "; }
  184.  
  185.     If you have an older Bourne shell, it's complicated but not impossible.
  186.     Here's one way.  Add this to your .profile file:
  187.  
  188.         LOGIN_SHELL=$$ export LOGIN_SHELL
  189.         CMDFILE=/tmp/cd.$$ export CMDFILE
  190.         PROMPTSIG=16 export PROMPTSIG
  191.         trap '. $CMDFILE' $PROMPTSIG
  192.  
  193.     and then put this executable script (without the indentation!),
  194.     let's call it "xcd", somewhere in your PATH 
  195.  
  196.         : xcd directory - change directory and set prompt
  197.         : by signalling the login shell to read a command file
  198.         cat >${CMDFILE?"not set"} <<EOF
  199.         cd $1
  200.         PS1="\`pwd\`$ "
  201.         EOF
  202.         kill -${PROMPTSIG?"not set"} ${LOGIN_SHELL?"not set"}
  203.  
  204.     Now change directories with "xcd /some/dir".
  205.  
  206.  
  207.     Korn Shell (ksh):
  208.  
  209.     Put this in your .profile file:
  210.         PS1='$PWD $ '
  211.     
  212.     If you just want the last component of the directory, use
  213.         PS1='${PWD##*/} $ '
  214.  
  215.  
  216. 5)  How do I read characters from a terminal without requiring the user
  217.     to hit RETURN?
  218.  
  219.     Check out cbreak mode in BSD, ~ICANON mode in SysV. 
  220.  
  221.     If you don't want to tackle setting the terminal parameters
  222.     yourself (using the "ioctl(2)" system call) you can let the stty
  223.     program do the work - but this is slow and inefficient, and you
  224.     should change the code to do it right some time:
  225.  
  226.     main()
  227.     {
  228.         int c;
  229.  
  230.         printf("Hit any character to continue\n");
  231.         /*
  232.          * ioctl() would be better here; only lazy
  233.          * programmers do it this way:
  234.          */
  235.         system("/bin/stty cbreak");
  236.         c = getchar();
  237.         system("/bin/stty -cbreak");
  238.         printf("Thank you for typing %c.\n", c);
  239.  
  240.         exit(0);
  241.     }
  242.  
  243.  
  244. 6)  How do I read characters from the terminal in a shell script?
  245.  
  246.     In sh, use read.  It is most common to use a loop like
  247.  
  248.         while read line
  249.         do
  250.             ...
  251.         done
  252.  
  253.     In csh, use $< like this:
  254.     
  255.         while ( 1 )
  256.         set line = "$<"
  257.         if ( "$line" == "" ) break
  258.         ...
  259.         end
  260.  
  261.     Unfortunately csh has no way of distinguishing between
  262.     a blank line and an end-of-file.
  263.  
  264.     If you're using sh and want to read a *single* character from
  265.     the terminal, you can try something like
  266.  
  267.         echo -n "Enter a character: "
  268.         stty cbreak
  269.         readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
  270.         stty -cbreak
  271.  
  272.         echo "Thank you for typing a $readchar ."
  273.  
  274. 7)  How do I check to see if there are characters to be read without
  275.     actually reading?
  276.  
  277.     Certain versions of UNIX provide ways to check whether
  278.     characters are currently available to be read from a file
  279.     descriptor.  In BSD, you can use select(2).  You can also use
  280.     the FIONREAD ioctl (see tty(4)), which returns the number of
  281.     characters waiting to be read, but only works on terminals,
  282.     pipes and sockets.  In System V Release 3, you can use poll(2),
  283.     but that only works on streams.  In Xenix - and therefore
  284.     Unix SysV r3.2 and later - the rdchk() system call reports
  285.     whether a read() call on a given file descriptor will block.
  286.  
  287.     There is no way to check whether characters are available to be
  288.     read from a FILE pointer.  (Well, there is no *good* way.  You could
  289.     poke around inside stdio data structures to see if the input buffer
  290.     is nonempty but this is a bad idea, forget about it.)
  291.  
  292.     Sometimes people ask this question with the intention of writing
  293.         if (characters available from fd)
  294.             read(fd, buf, sizeof buf);
  295.     in order to get the effect of a nonblocking read.  This is not the
  296.     best way to do this, because it is possible that characters will
  297.     be available when you test for availability, but will no longer
  298.     be available when you call read.  Instead, set the O_NDELAY flag
  299.     (which is also called FNDELAY under BSD) using the F_SETFL option
  300.     of fcntl(2).  Older systems (Version 7, 4.1 BSD) don't have O_NDELAY;
  301.     on these systems the closest you can get to a nonblocking read is
  302.     to use alarm(2) to time out the read.
  303.  
  304.  
  305. 8)  How do I find the name of an open file?
  306.  
  307.     In general, this is too difficult.  The file descriptor may
  308.     be attached to a pipe or pty, in which case it has no name.
  309.     It may be attached to a file that has been removed.  It may
  310.     have multiple names, due to either hard or symbolic links.
  311.  
  312.     If you really need to do this, and be sure you think long
  313.     and hard about it and have decided that you have no choice,
  314.     you can use find with the -inum and possibly -xdev option,
  315.     or you can use ncheck, or you can recreate the functionality
  316.     of one of these within your program.  Just realize that
  317.     searching a 600 megabyte filesystem for a file that may not
  318.     even exist is going to take some time.
  319.  
  320.  
  321. 9) How do I rename "*.foo" to "*.bar", or change file names to lowercase?
  322.     
  323.     Why doesn't "mv *.foo *.bar" work?  Think about how the shell
  324.     expands wildcards.   "*.foo" "*.bar" are expanded before the mv
  325.     command ever sees the arguments.  Depending on your shell, this
  326.     can fail in a couple of ways.  CSH prints "No match." because
  327.     it can't match "*.bar".  SH executes "mv a.foo b.foo c.foo *.bar",
  328.     which will only succeed if you happen to have a single
  329.     directory named "*.bar", which is very unlikely and almost
  330.     certainly not what you had in mind.
  331.  
  332.     Depending on your shell, you can do it with a loop to "mv" each
  333.     file individually.  If your system has "basename", you can use:
  334.  
  335.     C Shell:
  336.     foreach f ( *.foo )
  337.         set base=`basename $f .foo`
  338.         mv $f $base.bar
  339.     end
  340.  
  341.     Bourne Shell:
  342.     for f in *.foo; do
  343.         base=`basename $f .foo`
  344.         mv $f $base.bar
  345.     done
  346.  
  347.     Some shells have their own variable substitution features, so instead
  348.     of using "basename", you can use simpler loops like:
  349.  
  350.     C Shell:
  351.  
  352.     foreach f ( *.foo )
  353.         mv $f $f:r.bar
  354.     end
  355.  
  356.     Korn Shell:
  357.  
  358.     for f in *.foo; do
  359.         mv $f ${f%foo}bar
  360.     done
  361.     
  362.     If you don't have "basename" or want to do something like
  363.     renaming foo.* to bar.*, you can use something like "sed" to
  364.     strip apart the original file name in other ways, but
  365.     the general looping idea is the same.   
  366.  
  367.     A program called "ren" that does this job nicely was posted
  368.     to comp.sources.unix some time ago.  It lets you use
  369.  
  370.     ren '*.foo' '#1.bar'
  371.  
  372.     Shell loops like the above can also be used to translate
  373.     file names from upper to lower case or vice versa.  You could use
  374.     something like this to rename uppercase files to lowercase:
  375.  
  376.     C Shell:
  377.         foreach f ( * )
  378.         mv $f `echo $f | tr A-Z a-z`
  379.         end
  380.     Bourne Shell:
  381.         for f in *; do
  382.         mv $f `echo $f | tr A-Z a-z`
  383.         done
  384.  
  385.     If you wanted to be really thorough and handle files with
  386.     `funny' names (embedded blanks or whatever) you'd need to use
  387.     
  388.     Bourne Shell:
  389.  
  390.         for f in *; do
  391.         eval mv '"$i"' \"`echo "$i" | tr '[A-Z]' '[a-z]'`\"
  392.         done
  393.     
  394.     If you have the "perl" language installed, you may find this rename
  395.     script by Larry Wall very useful.  It can be used to accomplish a
  396.     wide variety of filename changes.
  397.  
  398.     #!/usr/bin/perl
  399.     #
  400.     # rename script examples from lwall:
  401.     #       rename 's/\.orig$//' *.orig
  402.     #       rename 'y/A-Z/a-z/ unless /^Make/' *
  403.     #       rename '$_ .= ".bad"' *.f
  404.     #       rename 'print "$_: "; s/foo/bar/ if <stdin> =~ /^y/i' *
  405.  
  406.     $op = shift;
  407.     for (@ARGV) {
  408.         $was = $_;
  409.         eval $op;
  410.         die $@ if $@;
  411.         rename($was,$_) unless $was eq $_;
  412.     }
  413.  
  414.  
  415. 10) Why do I get [some strange error message] when I "rsh host command" ?
  416.  
  417.     (We're talking about the remote shell program "rsh" or sometimes "remsh";
  418.      on some machines, there is a restricted shell called "rsh", which
  419.      is a different thing.)
  420.  
  421.     If your remote account uses the C shell, the remote host will
  422.     fire up a C shell to execute 'command' for you, and that shell
  423.     will read your remote .cshrc file.  Perhaps your .cshrc contains
  424.     a "stty", "biff" or some other command that isn't appropriate
  425.     for a non-interactive shell.  The unexpected output or error
  426.     message from these commands can screw up your rsh in odd ways.
  427.  
  428.     Fortunately, the fix is simple.  There are, quite possibly, a whole
  429.     *bunch* of operations in your ".cshrc" (e.g., "set history=N") that are
  430.     simply not worth doing except in interactive shells.  What you do is
  431.     surround them in your ".cshrc" with:
  432.  
  433.         if ( $?prompt ) then
  434.             operations....
  435.         endif
  436.  
  437.     and, since in a non-interactive shell "prompt" won't be set, the
  438.     operations in question will only be done in interactive shells.
  439.  
  440.     You may also wish to move some commands to your .login file; if
  441.     those commands only need to be done when a login session starts up
  442.     (checking for new mail, unread news and so on) it's better
  443.     to have them in the .login file.
  444.  
  445. 11) How do I find out the creation time of a file?
  446.  
  447.     You can't - it isn't stored anywhere.  Files have a last-modified
  448.     time (shown by "ls -l"), a last-accessed time (shown by "ls -lu")
  449.     and an inode change time (shown by "ls -lc"). The latter is often
  450.     referred to as the "creation time" - even in some man pages -  but
  451.     that's wrong; it's the time the file's status was last changed,
  452.     either by writing or changing the inode (via mv or chmod, etc...).
  453.  
  454.     The man page for "stat(2)" discusses this.
  455.  
  456. 12) How do I use "rsh" without having the rsh hang around until the
  457.     remote command has completed?
  458.  
  459.     (See note in question 10 about what "rsh" we're talking about.)
  460.  
  461.     The obvious answers fail:
  462.             rsh machine command &
  463.     or      rsh machine 'command &'
  464.  
  465.     The solution - if you use csh on the remote machine:
  466.  
  467.         rsh machine -n 'command >&/dev/null </dev/null &' 
  468.     
  469.     If you use sh on the remote machine:
  470.  
  471.         rsh machine -n 'command >/dev/null 2>&1 </dev/null &' 
  472.  
  473.     why?  "-n" attaches rsh's stdin to /dev/null so you could run the
  474.     complete rsh command in the background on the LOCAL machine.
  475.     Thus "-n" is equivalent to another specific "< /dev/null".
  476.     Furthermore, the input/output redirections on the REMOTE machine 
  477.     (inside the single quotes) ensure that rsh thinks the session can
  478.     be terminated (there's no data flow any more.)
  479.  
  480.     Note: on the remote machine, you needn't redirect to/from
  481.     /dev/null; any ordinary file will do.
  482.  
  483.     In many cases, various parts of these complicated commands
  484.     aren't necessary.
  485.  
  486. 13) How do I truncate a file?
  487.     
  488.     The BSD function ftruncate() sets the length of a file.  Xenix -
  489.     and therefore SysV r3.2 and later - has the chsize() system call.
  490.     For other systems, the only kind of truncation you can do is
  491.     truncation to length zero with creat() or open(..., O_TRUNC).
  492.  
  493. 14) How do I {set an environment variable, change directory} inside a
  494.     shell script and have that change affect my current shell?
  495.  
  496.     You can't, unless you use a special command to run the script in
  497.     the context of the current shell rather than in a child program.
  498.     The process environment (including environment variables and
  499.     current directory) is inherited by child programs but cannot be
  500.     passed back to parent programs.
  501.  
  502.     For instance, if you have a C shell script named "myscript":
  503.  
  504.     cd /very/long/path
  505.     setenv PATH /something:/something-else
  506.  
  507.     or the equivalent Bourne or Korn shell script
  508.  
  509.     cd /very/long/path
  510.     PATH=/something:/something-else export PATH
  511.  
  512.     and try to run "myscript" from your shell, your shell will fork and run
  513.     the shell script in a subprocess.  The subprocess is also
  514.     running the shell; when it sees the "cd" command it changes
  515.     *its* current directory, and when it sees the "setenv" command
  516.     it changes *its* environment, but neither has any effect on the current
  517.     directory of the shell at which you're typing (your login shell,
  518.     let's say).
  519.  
  520.     In order to get your login shell to execute the script (without forking)
  521.     you have to use the "." command (for the Bourne or Korn shells)
  522.     or the "source" command (for the C shell).  I.e. you type
  523.  
  524.     . myscript
  525.     
  526.     to the Bourne or Korn shells, or
  527.  
  528.     source myscript
  529.  
  530.     to the C shell.
  531.  
  532.     If all you are trying to do is change directory or set an
  533.     environment variable, it will probably be simpler to use a
  534.     C shell alias or Bourne/Korn shell function.  See the "how do
  535.     I get the current directory into my prompt" section
  536.     of this article for some examples.
  537.  
  538. 15) Why doesn't find's "{}" symbol do what I want?
  539.  
  540.     "find" has a -exec option that will execute a particular
  541.     command on all the selected files. Find will replace any "{}"
  542.     it sees with the name of the file currently under consideration.
  543.  
  544.     So, some day you might try to use "find" to run a command on every
  545.     file, one directory at a time.  You might try this:
  546.  
  547.     find /path -type d -exec command {}/\* \;
  548.  
  549.     hoping that find will execute, in turn
  550.  
  551.     command directory1/*
  552.     command directory2/*
  553.     ...
  554.     
  555.     Unfortunately, find only expands the "{}" token when it appears
  556.     by itself.  Find will leave anything else like "{}/*" alone, so
  557.     instead of doing what you want, it will do
  558.  
  559.     command {}/*
  560.     command {}/*
  561.     ...
  562.  
  563.     once for each directory.  This might be a bug, it might be a feature
  564.     but we're stuck with the current behaviour.
  565.  
  566.     So how do you get around this?  One way would be to write a
  567.     trivial little shell script, let's say "./doit", that
  568.     consists of
  569.     
  570.     command "$1"/*
  571.     
  572.     You could then use
  573.  
  574.     find /path -type d -exec ./doit {} \;
  575.  
  576.  
  577.     If all you're trying to do is cut down on the number of times
  578.     that "command" is executed, you should see if your system
  579.     has the "xargs" command.  Xargs reads arguments one line at a time
  580.     from the standard input and assembles as many of them as will fit into
  581.     one command line.  You could use
  582.  
  583.     find /path -print | xargs command
  584.     
  585.     which would result in
  586.  
  587.     command file1 file2 file3 file4 dir1/file1 dir1/file2
  588.     
  589.  
  590.     Unfortunately this is not a perfectly robust or secure solution.
  591.     Xargs expects its input lines to be terminated with newlines, so it
  592.     will be confused by files with odd characters such as newlines
  593.     in their names.
  594.  
  595.  
  596. 16) How do I redirect stdout and stderr separately in csh?
  597.  
  598.     In csh, you can redirect stdout with ">", or stdout and stderr
  599.     together with ">&" but there is no direct way to redirect
  600.     stderr only.  The best you can do is
  601.  
  602.         ( command >stdout_file ) >&stderr_file
  603.  
  604.     which runs "command" in a subshell;  stdout is redirected inside
  605.     the subshell to stdout_file, and both stdout and stderr from the
  606.     subshell are redirected to stderr_file, but by this point stdout
  607.     has already been redirected so only stderr actually winds up in
  608.     stderr_file.
  609.  
  610. 17) How do I set the permissions on a symbolic link?
  611.  
  612.     Permissions on a symbolic link don't really mean anything.  The
  613.     only permissions that count are the permissions on the file that
  614.     the link points to.
  615.  
  616.  
  617. 18) What does {awk,grep,fgrep,egrep,biff,cat,gecos,nroff,troff,tee,bss}
  618.     stand for?
  619.  
  620.     awk = "Aho Weinberger and Kernighan"
  621.  
  622.     This language was named by its authors, Al Aho, Peter Weinberger and
  623.     Brian Kernighan.
  624.  
  625.     grep = "Global Regular Expression Print"
  626.  
  627.     grep comes from the ed command to print all lines matching a
  628.     certain pattern
  629.  
  630.             g/re/p
  631.  
  632.     where "re" is a "regular expression".
  633.     
  634.     fgrep = "Fixed Grep".
  635.  
  636.     fgrep searches for fixed strings only.  The "f" does not
  637.     stand for "fast" - in fact, "fgrep foobar *.c" is usually slower
  638.     than "egrep foobar *.c"  (yes, this is kind of surprising. Try it.)
  639.  
  640.     Fgrep still has its uses though, and may be useful when searching
  641.     a file for a larger number of strings than egrep can handle.
  642.  
  643.     egrep = "Extended Grep"
  644.  
  645.     egrep uses fancier regular expressions than grep.
  646.     Many people use egrep all the time, since it has some more
  647.     sophisticated internal algorithms than grep or fgrep,
  648.     and is usually the fastest of the three programs.
  649.  
  650.     cat = "catenate"
  651.  
  652.     catenate is an obscure word meaning "to connect in a series",
  653.     which is what the "cat" command does to one or more files.
  654.     Not to be confused with C/A/T, the Computer Aided Typesetter.
  655.  
  656.     gecos = "General Electric Comprehensive Operating System"
  657.     
  658.     When GE's large systems division was sold to Honeywell,
  659.     Honeywell dropped the "E" from "GECOS".
  660.  
  661.     Unix's password file has a "pw_gecos" field.  The name is
  662.     a real holdover from the early days.  Dennis Ritchie
  663.     has reported:
  664.  
  665.         "Sometimes we sent printer output or batch jobs
  666.          to the GCOS machine.  The gcos field in the
  667.          password file was a place to stash the information
  668.          for the $IDENT card.  Not elegant."
  669.  
  670.     nroff = "New ROFF"
  671.     troff = "Typesetter ROFF"
  672.     
  673.     These are descendants of "roff", which was a re-implementation
  674.     of the Multics "runoff" program.
  675.     
  676.     tee    = T
  677.  
  678.     From plumbing terminology for a T-shaped pipe splitter.
  679.  
  680.     bss = "Block Started by Symbol"
  681.     
  682.     Dennis Ritchie says:
  683.  
  684.         Actually the acronym (in the sense we took it up; it may
  685.         have other credible etymologies) is "Block Started by Symbol."
  686.         It was a pseudo-op in FAP (Fortran Assembly [-er?] Program), an
  687.         assembler for the IBM 704-709-7090-7094 machines.  It defined
  688.         its label and set aside space for a given number of words.
  689.         There was another pseudo-op, BES, "Block Ended by Symbol"
  690.         that did the same except that the label was defined by
  691.         the last assigned word + 1.  (On these machines Fortran
  692.         arrays were stored backwards in storage and were 1-origin.)
  693.  
  694.         The usage is reasonably appropriate, because just as with
  695.         standard Unix loaders, the space assigned didn't have to
  696.         be punched literally into the object deck but was represented
  697.         by a count somewhere.
  698.  
  699.     biff = "biff"
  700.  
  701.         This command, which turns on asynchronous mail notification,
  702.     was actually named after a dog at Berkeley.
  703.  
  704.         I can confirm the origin of biff, if you're interested.  Biff
  705.         was Heidi Stettner's dog, back when Heidi (and I, and Bill Joy)
  706.         were all grad students at U.C. Berkeley and the early versions
  707.         of BSD were being developed.   Biff was popular among the
  708.         residents of Evans Hall, and was known for barking at the
  709.         mailman, hence the name of the command.
  710.  
  711.     Confirmation courtesy of Eric Cooper, Carnegie Mellon
  712.     University
  713.  
  714.     Don Libes' book "Life with Unix" contains lots more of these
  715.     tidbits.
  716.  
  717. 19) How do I pronounce "vi" , or "!", or "/*", or ...?
  718.  
  719.     You can start a very long and pointless discussion by wondering
  720.     about this topic on the net.  Some people say "vye", some say
  721.     "vee-eye" (the vi manual suggests this) and some Roman numerologists
  722.     say "six".  How you pronounce "vi" has nothing to do with whether
  723.     or not you are a true Unix wizard.
  724.  
  725.     Similarly, you'll find that some people pronounce "char" as "care",
  726.     and that there are lots of ways to say "#" or "/*" or "!" or
  727.     "tty" or "/etc".  No one pronunciation is correct - enjoy the regional
  728.     dialects and accents.  
  729.  
  730.     Since this topic keeps coming up on the net, here is a comprehensive
  731.     pronunciation list that has made the rounds in the past.
  732.     Origin unknown - please let me know if you know where it came from,
  733.     and I'll attribute it properly.
  734.  
  735.  
  736. Names derived from UNIX are marked with *, names derived from C are marked
  737. with +, and names deserving futher explanation are marked with a #.  The
  738. explanations will be given at the very end.
  739.  
  740. ------------------------------------------------------------------------------
  741.                -- SINGLE CHARACTERS --
  742.  
  743.      SPACE, blank
  744.  
  745. !    EXCLAMATION POINT, exclamation mark, exclamation, exclam, excl, clam,
  746.     bang#, shout, yell, shriek, pling, factorial, ball-bat, smash, cuss,
  747.     wow, hey, boing
  748.  
  749. "    QUOTATION MARK, quote, double quote, dirk, literal mark, rabbit ears,
  750.     double ping, double glitch
  751.  
  752. #    CROSSHATCH, pound, pound sign, number, number sign, sharp, octothorpe#,
  753.     hash, fence, crunch, mesh, hex, flash, grid, pig-pen, tictactoe,
  754.     scratch, scratch mark, gardengate, gate, hak, oof, rake, sink
  755.  
  756. $    DOLLAR SIGN, dollar, cash, currency symbol, buck, string#, escape#, 
  757.     ding, big-money
  758.  
  759. %    PERCENT SIGN, percent, mod+, shift-5, double-oh-seven, grapes
  760.  
  761. &    AMPERSAND, and, amper, address+, shift-7, andpersand, snowman,
  762.     bitand+, donald duck#, daemon
  763.  
  764. '    APOSTROPHE, single quote, quote, tick, prime, irk, pop, spark, glitch
  765.  
  766. *    ASTERISK, star, splat, spider, aster, times, wildcard*, gear, dingle,
  767.     (Nathan) Hale#, bug, gem, twinkle
  768.  
  769. ()   PARENTHESES, parens, round brackets, bananas, ears, bowlegs,
  770.     parenthesee (singular only), weapons
  771. (    LEFT PARENTHESIS,  paren,  so,      wax,  parenthesee,   open,  sad
  772. )    RIGHT PARENTHESIS, thesis, already, wane, unparenthesee, close, happy
  773.  
  774. +    PLUS SIGN, plus, add, cross, and, intersection, and
  775.  
  776. ,    COMMA, tail
  777.  
  778. -    HYPHEN, minus, minus sign, dash, dak, option, flag, negative,
  779.     negative sign, worm, bithorpe#
  780.  
  781. .    PERIOD, dot, decimal, decimal point, radix point, point, spot, full stop,
  782.     put#, floor
  783.  
  784. /    SLASH, stroke, virgule, solidus, slant, diagonal, over, slat, slak,
  785.     across#, compress#, spare
  786.  
  787. :    COLON, two-spot, double dot, dots
  788.  
  789. ;    SEMICOLON, semi, hybrid
  790.  
  791. <>   ANGLE BRACKETS, angles, funnels, brokets
  792. <    LESS THAN,    less, read from*, from*,        in*,  comesfrom*, crunch,
  793.     sucks
  794. >    GREATER THAN, more, write to*,  into/toward*, out*, gazinta*,   zap,
  795.     blows
  796.  
  797. =    EQUAL SIGN, equals, equal, gets, quadrathorpe#, half-mesh
  798.  
  799. ?    QUESTION MARK, question, query, whatmark, what, wildchar*, huh, ques,
  800.     kwes, quiz, quark, hook
  801.  
  802. @    AT SIGN, at, each, vortex, whorl, whirlpool, cyclone, snail, ape, cat,
  803.     snable-a#, trunk-a#, rose, cabbage, Mercantile symbol
  804.  
  805. []   BRACKETS, square brackets, U-turns, edged parentheses, mimics
  806. [    LEFT BRACKET,  bracket,   bra, square,   opensquare
  807. ]    RIGHT BRACKET, unbracket, ket, unsquare, close
  808.  
  809. \    BACKSLASH, reversed virgule, bash, backslant, backwhack, backslat, 
  810.     escape*, backslak, bak, reduce#
  811.  
  812. ^    CIRCUMFLEX, caret, carrot, hat, cap, uphat, party hat, housetop, 
  813.     up arrow, control, boink, chevron, hiccup, to-the, fang, sharkfin,
  814.     and#, xor+, wok, trap
  815.  
  816. _    UNDERSCORE, underline, underbar, under, score, backarrow, flatworm, blank
  817.  
  818. `    GRAVE, grave accent, accent, backquote, left/open quote, backprime, 
  819.     unapostrophe, backspark, birk, blugle, backtick, push, backglitch,
  820.     backping
  821.  
  822. {}   BRACES, curly braces, squiggly braces, curly brackets, squiggle brackets,
  823.     Tuborgs#, ponds
  824. {    LEFT BRACE,  brace,   curly,   leftit, embrace,  openbrace, begin+
  825. }    RIGHT BRACE, unbrace, uncurly, rytit,  bracelet, close,     end+
  826.  
  827. |    VERTICAL BAR, pipe*, pipe to*, vertical line, broken line#, bar, or+,
  828.     bitor+, vert, v-bar, spike, to*, gazinta*, thru*, pipesinta*, tube,
  829.     mark, whack, gutter, wall
  830.  
  831. ~    TILDE, twiddle, tilda, tildee, wave, squiggle, swung dash, approx, 
  832.     wiggle, enyay#, home*, worm
  833.  
  834.  
  835.             -- MULTIPLE CHARACTER STRINGS --
  836.  
  837. !?    interrobang (one overlapped character)
  838. /*       slashterix+
  839. */    asterslash+
  840. >>    appends*, cat-astrophe
  841. ->    arrow+, pointer to+, hiccup+
  842. #!    sh'bang, wallop
  843. \!*    bash-bang-splat
  844. ()    nil#
  845. &&    and+, amper-amper, succeeds-then*
  846. ||    or+, fails-then*
  847.  
  848.  
  849.                 -- NOTES --
  850.  
  851. ! bang        comes from old card punch phenom where punching ! code made a
  852.         loud noise
  853. # octothorpe    from Bell System
  854. $ string    from BASIC
  855. $ escape    from TOPS-10
  856. & donald duck    from the Danish "Anders And", which means "Donald Duck"
  857. * splat        from DEC "spider" glyph
  858. * Nathan Hale    "I have but one asterisk for my country."
  859. = quadrathorpe    half an octothorpe
  860. - bithorpe    half a quadrathorpe (So what's a monothorpe?)
  861. . put        Victor Borge on Electric Company
  862. / across    APL
  863. / compress    APL
  864. @ snable-a    from Danish; may translate as "trunk-a"
  865. @ trunk-a    "trunk" = "elephant nose"
  866. ^ and        from formal logic
  867. \ reduce    APL
  868. {} Tuborgs    from advertizing for well-known Danish beverage
  869. | broken line    EBCDIC has two vertical bars, one solid and one broken.
  870. ~ enyay        from the Spanish n-tilde
  871. () nil        LISP
  872.  
  873.  
  874. -- 
  875. Steve Hayman    Workstation Manager    Computer Science Department   Indiana U.
  876. sahayman@iuvax.cs.indiana.edu     iuvax!sahayman                 (812) 855-6984
  877.  
  878.  
  879.