1. Audible notification of a background process finishing
The character CONTROL-G will cause your terminal to beep. If you
want to use it to have your terminal beep at you when a background
process finishes, type the following:
(anycommand ; echo \^G\^G\) &
Note that the two commands are clumped together by parentheses,
and separated by a semicolon. The echo command simply beeps three
times. It will not run until "anycommand" has finished. The &
ampersand of course puts the whole thing in the background so that
you can do other work while anycommand executes.
2. Self-identifying C programs
If you have a binary file such as "a.out" or "xyz.o" and you want to
know what it does without the possibly dangerous results of trying to
run it, try doing "strings" on it. This will find any and all error
messages and other strings that are in the program:
strings a.out
It is also a good idea to put strings into your own C programs so
that anyone doing this trick can see the purpose of your code. Just
declare an array or 2 at the top-level (i.e. outside of any function)
such as:
char explain1[]="This program was designed to parse a line."
char explain2[]="It breaks up the input into separate words."
char explain3[]="Each word is put into a new malloc string."
3. Identify yourself to the world!
You cannot change your username, but you can give out some information
about yourself. If you do "finger username" to find out who "username"
is, you'll see the extent of the public info. Some of that info comes
from two text files in your accounts: .plan and .project.
.project should have only 1 line in it, whereas .plan can be as long
as you like.
4. Create use of shell commands
Here's a neat trick that easily renames all files in a given directory.
Suppose that there are many files whose names end in ".txt" They probably
came from an MS-DOS environment. You want to strip off the ending because
the .txt is just extra junk to type in and serves no special purpose.
Here are UNIX commands that will rename all these files in the current
directory:
% foreach i (*)
? mv $i `basename $i .txt`
? end
Note that when you type the foreach line, UNIX knows that you are not done
specifying this looping control structure until you type in "end" Thus it
gives you the ? prompt.
Basename is a UNIX command that gets the prefix of a filename. The .txt
part tells what the suffix is that should be stripped off.