Unix commands
(Unix programs and tcsh shell commands)
Shell commands (get help from the shell man page, e.g. 'man tcsh' or 'man bash')
cd - change directories
Examples:
cd
cd $HOME
cd suma_demo
cd AFNI_data6/FT_analysis
cd ~username
cd /absolute/path/to/some/directory
cd relative/path/to/some/directory
cd ../../some/other/dir
The 'cd' command is used to change directories. Without any parameters,
the shell will change to the user's home directory ($HOME). Otherwise,
it will change to the single specified directory.
Note that since '..' is the parent directory, including such entries will
travel up the directory tree.
It is a good idea to follow a 'cd' command with 'ls' to see what is there.
for more help, see 'man tcsh'
echo - echo text to the terminal window
Examples:
echo hello there
echo "this section performs volume registration"
set my_var = 7
echo "the value of my_var = $my_var"
The echo command displays the given text on the terminal window. This is
often used to show the user what is happening or to prompt for a response.
There are more devious uses, of course...
for more help, see 'man tcsh'
set - assing a value to a variable (tcsh)
Examples:
set
set value = 7
set new_val = "some number, like seven"
echo $new_val
set list_of_vals = ( 3 1 4 one five )
echo $list_of_vals
echo $list_of_vals[3]
set path = ( $path ~/abin )
The set command assigns a value to a variable (or multiple values to
multiple variables). Without any options, all set variables are shown.
If a value has spaces in it, it should be contained in quotes. If a list
of values is desired, parentheses '()' should be used for the assignment,
while indivisual access is done via square brackets '[]'.
Note: a single 'set' command can be used to set many variables, but such a
use is not recommended (as it is error prone).
Note: 'set' is for setting shell variables, which do not survive to child
shells. To survive to a child shell, use envirionment variables. A
child shell would be created when a new shell is started, such as when
running a script.
setenv DYLD_FALLBACK_LIBRARY_PATH $HOME/abin
See setenv.
bash: uses '=' assignment to set variables, which can be exported to the
environment via export. Lists are separated by ':', not space.
value=7
list_of_vals=3:1:4:one:five
export list_of_vals
export DYLD_FALLBACK_LIBRARY_PATH=$HOME/abin
for more help, see 'man tcsh'
See also setenv.
See also unset.
setenv - set an environment variable
Examples:
setenv MY_ENV_VAR "some value"
setenv PATH ${PATH}:$HOME/abin
setenv DYLD_FALLBACK_LIBRARY_PATH $HOME/abin
The setenv command works like 'set', except that if a child shell is started
(such as when running a script), the environment variables are preserved.
Note that environment variables are generally in all caps by convention, to
visually distinguish them from regular shell variables.
Lists are assigned using the bash-like syntax of ':' delimited elements,
rather than with '()' and space delimited elements as 'set' uses. When a
list is added to, as with the $PATH example, the variable should be within
'{}', so that the ':' does not look like a modifier (i.e. using ${PATH}
rather than just $PATH).
bash: 'export' a currently set variable, or add export to an assignment.
name="Maria Buttersworth"
export name
export name="Maria Buttersworth"
export DYLD_FALLBACK_LIBRARY_PATH=$HOME/abin
for more help, see 'man tcsh'
See also set.
See also unsetenv.
Unix commands (get help from individual man pages)
cat - display file contents in terminal window
Examples:
cat AFNI_data6/FT_analysis/s01.ap.simple
cat here are four files
cat here are four files | wc -l
The cat command, short for catenate, is meant to dump all files on the
command line to the terminal window.
for more help, see 'man cat'
jobs - list processes started from current shell
Examples:
jobs - probably shows nothing
See the example from ctrl-z: help for ctrl-z
The 'jobs' command lists processes that have been started from the current
shell (the current terminal window, probably) that are either suspended or
running in the background. Processes are suspended via ctrl-z, and can then
be put into the background using the 'bg' command (or by using & in the
first place).
for more help, see 'man jobs'
Note that 'jobs' is an internal command (to tcsh or bash, say), so the
actual description might come from 'man tcsh', 'man bash' or a Unix book.
ls - list directory contents
Examples:
ls
ls $HOME
ls AFNI_data6/afni
ls AFNI_data6/afni AFNI_data6/FT_analysis/FT ~
ls -al
ls -ltr
ls -ltr ~
ls -lSr dir.with.big.files
The 'ls' command lists the contents of either the current directory or the
directories listed on the command line. For files listed on the command
line, it just lists them.
Multiple directories may be listed, in which case each directory is shows
one by one.
Options:
-a : list all files/directories, including those starting with '.'
-l : use the long format, which includes:
type, permissions, ownership, size, date (may vary per OS)
-t : sort by time (modification time)
-r : reverse sort order
-S : sort by size of file (e.g. 'ls -lSr')
for more help, see 'man ls'
pwd - show present working directory
Examples:
pwd
The pwd command just shows the present working directory.
for more help, see 'man pwd'
Special characters and keystrokes (get extra help from a Unix book)
ctrl-c - terminate a running process
Example of usage:
1. run 'ccalc'
(the prompt is now waiting for an input expression to evaluate)
2. type 3+5 and hit <Enter>
(it should show the result: Z = 8)
3. terminate the program with ctrl-c
(the prompt should now be back)
help for ccalc
The ctrl-c (while holding the control key down, press c) keystroke is used
to terminate the foreground process in the current shell (by sending it a
SIGINT signal).
This might be useful when running a shell script that would take a while to
complete. Maybe you decide to make a change, or error messages start
coming out. If that script is running in the foreground, entering ctrl-c
should terminate it.
ctrl-z - suspend a running process
Example of usage:
ccalc
3+5 - should show the result Z = 8
ctrl-z - process 'Suspended', prompt should be back
ls - works, can type other commands
jobs - shows that 'ccalc' is still suspended
fg - put 'ccalc' back in the foreground
3-4 - should show the result Z = -1
quit - quit ccalc program
help for ccalc
help for jobs
The ctrl-c (while holding the control key down, press c) keystroke is used
to terminate the foreground process in the current shell (by sending it a
SIGINT signal).
This might be useful when running a shell script that would take a while to
complete. Maybe you decide to make a change, or error messages start
coming out. If that script is running in the foreground, entering ctrl-c
should terminate it.