home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / n_z / nia022.hac < prev    next >
Encoding:
Text File  |  2003-06-11  |  38.7 KB  |  1,049 lines

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