In general, how to pass information to a program:
See what is installed:
ls -l /bin/*shOn DCU Linux, something like:
On DCU Solaris, something like:-rwxr-xr-x 1 root root 663704 2008-06-06 21:04 /bin/bash lrwxrwxrwx 1 root root 4 2008-09-11 12:47 /bin/csh -> tcsh lrwxrwxrwx 1 root root 16 2008-09-11 12:48 /bin/ksh -> /lib/ast/bin/ksh -rwxr-xr-x 1 root root 705552 2008-06-06 21:44 /bin/sash lrwxrwxrwx 1 root root 4 2008-09-11 12:42 /bin/sh -> bash -rwxr-xr-x 1 root root 334380 2008-06-06 20:48 /bin/tcsh -rwxr-xr-x 1 root root 569692 2008-06-07 09:18 /bin/zsh
-r-xr-xr-x 1 root bin 578964 Mar 2 2002 /bin/bash -r-xr-xr-x 2 root bin 159332 Apr 6 2002 /bin/csh -r-xr-xr-x 17 root bin 134 Apr 6 2002 /bin/hash -r-xr-xr-x 4 root root 95488 Apr 7 2002 /bin/jsh -r-xr-xr-x 3 root bin 201044 Mar 14 2003 /bin/ksh -r-xr-xr-x 2 root bin 159332 Apr 6 2002 /bin/pfcsh -r-xr-xr-x 3 root bin 201044 Mar 14 2003 /bin/pfksh -r-xr-xr-x 4 root root 95488 Apr 7 2002 /bin/pfsh lrwxrwxrwx 1 root root 5 Nov 7 2002 /bin/remsh -> ./rsh -r-xr-xr-x 3 root bin 201044 Mar 14 2003 /bin/rksh -r-sr-xr-x 1 root bin 9176 Apr 6 2002 /bin/rsh -r-xr-xr-x 4 root root 95488 Apr 7 2002 /bin/sh -r-xr-xr-x 1 root bin 737948 Apr 7 2002 /bin/ssh -r-xr-xr-x 1 root bin 358848 Mar 2 2002 /bin/tcsh -r-xr-xr-x 1 root bin 474736 Mar 2 2002 /bin/zsh
To start using one as the command-line, just type its name. e.g.
ksh"exit" to return.
The first line
of a shell script
should state which shell
it is to run in, using syntax like:
This is called a "shebang" line.
Can have endless number of interpreters of source text. Can invent your own.
But you cannot depend on this
- exactly what happens depends on each system.
Your shell scripts may not be portable to different UNIX-family systems.
So it is good practice to define the shell in the first line.
HOME=/users/gdf1/mhtest09 OSTYPE=linux PATH=/users/gdf1/mhtest09/bin:/usr/local/bin:/usr/bin:/bin:.... PWD=/users/gdf1/mhtest09/bin SHELL=/bin/bash USER=mhtest09 USERNAME=mhtest09 http_proxy=http://wwwproxy.computing.dcu.ie:8000 no_proxy='localhost, 127.0.0.1, dcu.ie'
cwd /users/gdf1/mhtest09 home /users/gdf1/mhtest09 path (/users/gdf1/mhtest09/bin /usr/local/bin /usr/bin /bin ....) shell /bin/tcsh user mhtest09
if test $1 = ""
x=3 export x echo "prog1 [$x]" prog2
echo "prog2 [$x]"
Try it with and without export.
export will make variable x available to a script called by this script, and any scripts called by that script, etc., without any further exporting needed. Only a single export statement is needed (in the top parent script).
It is a bit of an overhead
to search all the directories in the PATH on disk
every time you type a command.
So some shells 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.
source .FILEwhere .FILE (insert correct file name) is the file where the path is defined.
If you do this a lot, you might like to put the following alias in .cshrc:
alias redo source $home/.FILEor .bashrc:
alias redo="source $HOME/.FILE"And then, every time your PATH cache seems to be out of date, you just type:
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.
echo '\0nn' echo char by octal numeric code (on csh) echo '\0nnn' echo -e (string) on bash echo "\0115" echo "M" echo "\0275" echo "½" works on csh on DCU Linux works on sh on DCU Solaris ASCII chars ISO/IEC 8859 To build list of chars