Put all your utilities in a directory called "shell".
Edit your .cshrc file to add this directory to the PATH:
set path = ( . $home/shell /bin /usr/local/bin .... )Now you can call those utilities from the command-line wherever you are.
Type "which ls" to see the location of the system ls program. Write your own ls, insert it in a directory in the path which comes before that system directory. You have now over-ridden the system ls.
Not just that, but other programs that call ls will now be calling your version instead. This is very "object-oriented" (the "virtual function call" is resolved to an actual function call at run-time, and can be re-mapped at any time).
Also, if you are in someone else's directory, and read is off and "." is in the PATH, you will find strange effects.
It would actually be quite an overhead to search all the directories in the PATH on disk every time you type a command. So what the system does is make a list of executable files in these directories (with the exception of ".") once, at login, or at the start of running a script, and then caches that list in memory for future use. This can cause some problems. e.g. You add a new program to your $home/bin directory, which is in the PATH. You then type the name of the program at the command-line and it says "Command not found". The solution is you need to re-build that cache, by typing:
source .cshrcIf you do this a lot, you might like to put the following alias in your .cshrc file:
alias redo source $home/.cshrcAnd then, every time your PATH cache seems to be out of date, you just type:
redoOr see rehash
The "cdpath" variable is also very useful:
set cdpath = ( $home $home/public_html )It is a quick way of jumping around the disk. Wherever you are on the disk, you can jump direct to a subdirectory off your home directory or off your web directory by just typing "cd (subdirectory)". Using tools like this, jumping around the disk and performing tasks on the command-line can actually be quicker than doing it through the File Manager.
grep search for a string ^ start-of-line $ end-of-line . any character where "c" stands for the character: c* 0 or more instances of c cc* 1 or more instances of c e.g. grep " *" 1 or more spaces .* any sequence of characters where "c" has a special meaning, e.g. is $ or ., etc: \c the character itself e.g. \. the '.' character itself e.g. Peek at your incoming mail: ls -l /var/mail/$user grep '^From ' /var/mail/$user
cut extract columns of text on command-line e.g. To extract the RHS columns of the ls listing: ls -l | cut -f6- -d' ' sed substitute text on the command-line e.g. To do an ls that highlights the HTML files: ls -l | sed 's|\.html| [Hypertext HTML file]|g' sed takes a single string (enclosed in quotes) as an argument. The '|' inside the string above are used just as separators. We can actually use any character. If you use '|' then the sed command looks like: sed 's|oldstring|newstring|g'
tr (see "man tr") is also useful for character substitutions see tr character classes (numeric, alphanumeric, etc.) also here awk a powerful pattern scanning and processing language
dirname basename$ echo $home /users/group/me $ dirname $home /users/group $ basename $home me $ dirname `dirname $home` /usersRecall putting the current dir in the prompt. You might like to try this: alias setprompt 'set prompt="[`hostname`] `basename $cwd`> "'