Diffs to the Frequently Asked Questions postings
Steve Hayman
sahayman at iuvax.cs.indiana.edu
Tue Jul 3 07:43:06 AEST 1990
Here are the most recent changes to parts 1 and 2 of the
Frequently Asked Questions articles, which have just been
posted. You can find the full articles elsewhere in
comp.unix.questions and comp.unix.wizards. You can also ftp
the most recent version from iuvax.cs.indiana.edu (129.79.254.192),
where it's "pub/Unix-Questions.part1" and "pub/Unix-Questions.part2".
*** /tmp/,RCSt1a09210 Mon Jul 2 16:41:57 1990
--- part2 Mon Jul 2 16:39:06 1990
***************
*** 1,6 ****
Subject: Frequently Asked Questions about Unix - with Answers [Monthly posting]
! [Last changed: $Date: 90/06/01 14:28:10 $ by $Author: sahayman $]
This article contains the answers to some Frequently Asked Questions
often seen in comp.unix.questions and comp.unix.wizards. Please don't
--- 1,6 ----
Subject: Frequently Asked Questions about Unix - with Answers [Monthly posting]
! [Last changed: $Date: 90/07/02 16:38:51 $ by $Author: sahayman $]
This article contains the answers to some Frequently Asked Questions
often seen in comp.unix.questions and comp.unix.wizards. Please don't
***************
*** 41,47 ****
20) How does the gateway between "comp.unix.questions" and the
"info-unix" mailing list work?
21) How do I "undelete" a file?
! 22) How do I pronounce "vi" , or "!", or "/*", or ...?
If you're looking for the answer to, say, question 14, and want to skip
--- 41,48 ----
20) How does the gateway between "comp.unix.questions" and the
"info-unix" mailing list work?
21) How do I "undelete" a file?
! 22) How can a process detect if it's running in the background?
! 23) How do I pronounce "vi" , or "!", or "/*", or ...?
If you're looking for the answer to, say, question 14, and want to skip
***************
*** 94,105 ****
rm -ri .
! which asks you whether to remove each file in the directory,
! answer "y" to the problem file and "n" to everything else,
! and which, unfortunately, doesn't work with many versions of rm
! (always take a deep breath and think about what you're doing
! and double check what you typed when you use rm's "-r" flag);
and
find . -type f ... -ok rm '{}' \;
--- 95,111 ----
rm -ri .
! which asks you whether to remove each file in the directory.
! Answer "y" to the problem file and "n" to everything else.
! Unfortunately this doesn't work with many versions of rm.
! Also unfortunately, this will walk through every subdirectory
! of ".", so you might want to "chmod a-x" those directories
! temporarily to make them unsearchable.
+ Always take a deep breath and think about what you're doing
+ and double check what you typed when you use rm's "-r" flag
+ or a wildcard on the command line;
+
and
find . -type f ... -ok rm '{}' \;
***************
*** 187,192 ****
--- 193,199 ----
LOGIN_SHELL=$$ export LOGIN_SHELL
CMDFILE=/tmp/cd.$$ export CMDFILE
+ # 16 is SIGURG, pick some signal that isn't likely to be used
PROMPTSIG=16 export PROMPTSIG
trap '. $CMDFILE' $PROMPTSIG
***************
*** 212,218 ****
--- 219,237 ----
If you just want the last component of the directory, use
PS1='${PWD##*/} $ '
+ T C shell (tcsh)
+
+ Tcsh is a popular enhanced version of csh with some extra
+ builtin variables (and many other features):
+
+ %~ the current directory, using ~ for $HOME
+ %d or %/ the full pathname of the current directory
+ %c or %. the trailing component of the current directory
+
+ so you can do
+ set prompt='%~ '
+
5) How do I read characters from a terminal without requiring the user
to hit RETURN?
***************
*** 223,228 ****
--- 242,248 ----
program do the work - but this is slow and inefficient, and you
should change the code to do it right some time:
+ #include <stdio.h>
main()
{
int c;
***************
*** 232,238 ****
* ioctl() would be better here; only lazy
* programmers do it this way:
*/
! system("/bin/stty cbreak");
c = getchar();
system("/bin/stty -cbreak");
printf("Thank you for typing %c.\n", c);
--- 252,258 ----
* ioctl() would be better here; only lazy
* programmers do it this way:
*/
! system("/bin/stty cbreak"); /* or "stty raw" */
c = getchar();
system("/bin/stty -cbreak");
printf("Thank you for typing %c.\n", c);
***************
*** 272,278 ****
the terminal, you can try something like
echo -n "Enter a character: "
! stty cbreak
readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
stty -cbreak
--- 292,298 ----
the terminal, you can try something like
echo -n "Enter a character: "
! stty cbreak # or stty raw
readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
stty -cbreak
***************
*** 292,300 ****
whether a read() call on a given file descriptor will block.
There is no way to check whether characters are available to be
! read from a FILE pointer. (Well, there is no *good* way. You could
! poke around inside stdio data structures to see if the input buffer
! is nonempty but this is a bad idea, forget about it.)
Sometimes people ask this question with the intention of writing
if (characters available from fd)
--- 312,321 ----
whether a read() call on a given file descriptor will block.
There is no way to check whether characters are available to be
! read from a FILE pointer. (You could poke around inside stdio data
! structures to see if the input buffer is nonempty, but that wouldn't
! work since you'd have no way of knowing what will happen the next
! time you try to fill the buffer.)
Sometimes people ask this question with the intention of writing
if (characters available from fd)
***************
*** 369,376 ****
If you don't have "basename" or want to do something like
renaming foo.* to bar.*, you can use something like "sed" to
strip apart the original file name in other ways, but
! the general looping idea is the same.
A program called "ren" that does this job nicely was posted
to comp.sources.unix some time ago. It lets you use
--- 390,401 ----
If you don't have "basename" or want to do something like
renaming foo.* to bar.*, you can use something like "sed" to
strip apart the original file name in other ways, but
! the general looping idea is the same. You can also convert
! file names into "mv" commands with 'sed', and hand the commands
! off to "sh" for execution. Try
+ ls -d *.foo | sed -e 's/.*/mv & &/' -e 's/foo$/bar/' | sh
+
A program called "ren" that does this job nicely was posted
to comp.sources.unix some time ago. It lets you use
***************
*** 496,503 ****
(inside the single quotes) ensure that rsh thinks the session can
be terminated (there's no data flow any more.)
! Note: on the remote machine, you needn't redirect to/from
! /dev/null; any ordinary file will do.
In many cases, various parts of these complicated commands
aren't necessary.
--- 521,528 ----
(inside the single quotes) ensure that rsh thinks the session can
be terminated (there's no data flow any more.)
! Note: The file that you redirect to/from on the remote machine
! doesn't have to be /dev/null; any ordinary file will do.
In many cases, various parts of these complicated commands
aren't necessary.
***************
*** 579,585 ****
command {}/*
...
! once for each directory. This might be a bug, it might be a feature
but we're stuck with the current behaviour.
So how do you get around this? One way would be to write a
--- 604,610 ----
command {}/*
...
! once for each directory. This might be a bug, it might be a feature,
but we're stuck with the current behaviour.
So how do you get around this? One way would be to write a
***************
*** 599,605 ****
--- 624,635 ----
(This works because within the 'command' of "sh -c 'command' A B C ...",
$0 expands to A, $1 to B, and so on.)
+ or you can use the construct-a-command-with-sed trick
+
+ find /path -type d -print | sed 's:.*:command &/*:' | sh
+
+
If all you're trying to do is cut down on the number of times
that "command" is executed, you should see if your system
has the "xargs" command. Xargs reads arguments one line at a time
***************
*** 652,658 ****
"man 3 ctime" to look up the manual page for "ctime" in section 3
of the manual.
! The standard manual sections are:
1 User-level commands
2 System calls
--- 682,688 ----
"man 3 ctime" to look up the manual page for "ctime" in section 3
of the manual.
! The traditional manual sections are:
1 User-level commands
2 System calls
***************
*** 700,715 ****
where "re" is a "regular expression".
! fgrep = "Fixed Grep".
fgrep searches for fixed strings only. The "f" does not
stand for "fast" - in fact, "fgrep foobar *.c" is usually slower
! than "egrep foobar *.c" (yes, this is kind of surprising. Try it.)
Fgrep still has its uses though, and may be useful when searching
a file for a larger number of strings than egrep can handle.
! egrep = "Extended Grep"
egrep uses fancier regular expressions than grep.
Many people use egrep all the time, since it has some more
--- 730,745 ----
where "re" is a "regular expression".
! fgrep = "Fixed GREP".
fgrep searches for fixed strings only. The "f" does not
stand for "fast" - in fact, "fgrep foobar *.c" is usually slower
! than "egrep foobar *.c" (Yes, this is kind of surprising. Try it.)
Fgrep still has its uses though, and may be useful when searching
a file for a larger number of strings than egrep can handle.
! egrep = "Extended GREP"
egrep uses fancier regular expressions than grep.
Many people use egrep all the time, since it has some more
***************
*** 716,722 ****
sophisticated internal algorithms than grep or fgrep,
and is usually the fastest of the three programs.
! cat = "catenate"
catenate is an obscure word meaning "to connect in a series",
which is what the "cat" command does to one or more files.
--- 746,752 ----
sophisticated internal algorithms than grep or fgrep,
and is usually the fastest of the three programs.
! cat = "CATenate"
catenate is an obscure word meaning "to connect in a series",
which is what the "cat" command does to one or more files.
***************
*** 740,746 ****
troff = "Typesetter ROFF"
These are descendants of "roff", which was a re-implementation
! of the Multics "runoff" program.
tee = T
--- 770,777 ----
troff = "Typesetter ROFF"
These are descendants of "roff", which was a re-implementation
! of the Multics "runoff" program (a program that you'd use to
! "run off" a good copy of a document).
tee = T
***************
*** 843,848 ****
--- 874,883 ----
and find you just deleted "*" instead of "*.foo". Consider it a rite
of passage.
+ Of course, any decent systems administrator should be doing regular
+ backups. Check with your sysadmin to see if a recent backup copy
+ of your file is available. But if it isn't, read on.
+
For all intents and purposes, when you delete a file with "rm" it is
gone. Once you "rm" a file, the system totally forgets which blocks
scattered around the disk comprised your file. Even worse, the blocks
***************
*** 888,894 ****
complete replacement for rm which allows file recovery. This
package was posted to comp.sources.unix (volume 18, issue 73).
! 22) How do I pronounce "vi" , or "!", or "/*", or ...?
You can start a very long and pointless discussion by wondering
about this topic on the net. Some people say "vye", some say
"vee-eye" (the vi manual suggests this) and some Roman numerologists
--- 923,950 ----
complete replacement for rm which allows file recovery. This
package was posted to comp.sources.unix (volume 18, issue 73).
!
! 22) How can a process detect if it's running in the background?
!
! In general, you can't. The fundamental problem is that different
! shells and different versions of UNIX have different notions of
! what "foreground" and "background" mean - and on the most common
! type of system with a better-defined notion of what they mean,
! programs can be moved arbitrarily between foreground and background!
!
! UNIX systems without job control typically put a process into the
! background by ignoring SIGINT and SIGQUIT and redirecting the standard
! input to "/dev/null"; this is done by the shell.
!
! Shells that support job control, on UNIX systems that support job
! control, put a process into the background by giving it a process group
! ID different from the process group to which the terminal belongs. They
! move it back into the foreground by setting the terminal's process group
! ID to that of the process. Shells that do *not* support job control, on
! UNIX systems that support job control, typically do what shells do on
! systems that don't support job control.
!
! 23) How do I pronounce "vi" , or "!", or "/*", or ...?
You can start a very long and pointless discussion by wondering
about this topic on the net. Some people say "vye", some say
"vee-eye" (the vi manual suggests this) and some Roman numerologists
***************
*** 904,909 ****
--- 960,969 ----
pronunciation list that has made the rounds in the past. This list
is maintained by Maarten Litmaath, maart at cs.vu.nl .
+ The Pronunciation Guide
+ -----------------------
+ version 2.1
+
Names derived from UNIX are marked with *, names derived from C are marked
with +, names derived from (Net)Hack are marked with & and names deserving
futher explanation are marked with a #. The explanations will be given at
***************
*** 922,938 ****
double ping, double glitch, amulet&, web&, inverted commas
# CROSSHATCH, pound, pound sign, number, number sign, sharp, octothorpe#,
! hash, fence, crunch, mesh, hex, flash, grid, pig-pen, tictactoe,
! scratch (mark), (garden)gate, hak, oof, rake, sink&, corridor&,
! unequal#
$ DOLLAR SIGN, dollar, cash, currency symbol, buck, string#, escape#,
! ding, big-money, gold&
% PERCENT SIGN, percent, mod+, shift-5, double-oh-seven, grapes, food&
& AMPERSAND, and, amper, address+, shift-7, andpersand, snowman,
! bitand+, donald duck#, daemon&, background*
' APOSTROPHE, (single) quote, tick, prime, irk, pop, spark, glitch,
lurker above&
--- 982,998 ----
double ping, double glitch, amulet&, web&, inverted commas
# CROSSHATCH, pound, pound sign, number, number sign, sharp, octothorpe#,
! hash, (garden) fence, crunch, mesh, hex, flash, grid, pig-pen,
! tictactoe, scratch (mark), (garden) gate, hak, oof, rake, sink&,
! corridor&, unequal#
$ DOLLAR SIGN, dollar, cash, currency symbol, buck, string#, escape#,
! ding, big-money, gold&, Sonne#
% PERCENT SIGN, percent, mod+, shift-5, double-oh-seven, grapes, food&
& AMPERSAND, and, amper, address+, shift-7, andpersand, snowman,
! bitand+, donald duck#, daemon&, background*, pretzel
' APOSTROPHE, (single) quote, tick, prime, irk, pop, spark, glitch,
lurker above&
***************
*** 958,964 ****
/ SLASH, stroke, virgule, solidus, slant, diagonal, over, slat, slak,
across#, compress#, reduce#, replicate#, spare, divided-by, wand&,
! forward slash
: COLON, two-spot, double dot, dots, chameleon&
--- 1018,1024 ----
/ SLASH, stroke, virgule, solidus, slant, diagonal, over, slat, slak,
across#, compress#, reduce#, replicate#, spare, divided-by, wand&,
! forward slash, shilling#
: COLON, two-spot, double dot, dots, chameleon&
***************
*** 1040,1045 ****
--- 1100,1111 ----
loud noise; however, this pronunciation is used in the (non-
computerized) publishing and typesetting industry in the U.S.
too, so ...
+ Alternatively it could have come from comic books, where the
+ words each character utters are shown in a "balloon" near that
+ character's head. When one character shoots another, it is
+ common to see a balloon pointing at the barrel of the gun to
+ denote that the gun had been fired, not merely aimed.
+ That balloon contained the word "!" -- hence, "!" == "Bang!"
! store from FORTH
! dammit as in "quit, dammit!" while exiting vi and hoping one hasn't
clobbered a file too badly
***************
*** 1047,1052 ****
--- 1113,1131 ----
# unequal e.g. Modula-2
$ string from BASIC
$ escape from TOPS-10
+ $ Sonne In the "socialist" countries they used and are using all kinds
+ of IBM clones (hardware + sw). It was a common practice just
+ to rename everything (IBM 360 --> ESER 1040 etc.).
+ Of course the "dollar" sign had to be renamed - it became the
+ "international currency symbol" which looks like a circle with
+ 4 rays spreading from it:
+
+ \ /
+ O
+ / \
+
+ Because it looks like a (small) shining sun it was usually
+ called "Sonne" (sun).
& donald duck from the Danish "Anders And", which means "Donald Duck"
* splat from DEC "spider" glyph
* Nathan Hale "I have but one asterisk for my country."
***************
*** 1063,1068 ****
--- 1142,1148 ----
/ compress APL
/ reduce APL
/ replicate APL
+ / shilling from the British currency symbol
:= becomes e.g. Pascal
; go-on Algol68
< left chevron from the military: worn vertically on the sleeve to signify
More information about the Comp.unix.wizards
mailing list