More UNIX

.cshrc

Defines settings for all C-Shell sessions, including all invocations of a shell script.
Beware recursion: Do not call a shell script in .cshrc.

.login

Runs once, when you log in.
Can call a shell script in here.

e.g. To put the current dir into the prompt, put the following in .cshrc:

alias setprompt  'set prompt="[`hostname`] `pwd`> "'
alias cd         'cd \!*; setprompt'
and the following in .login to get it started:
setprompt
Question - Why can we not simply put this in .cshrc:
set prompt="[`hostname`] `pwd`> "
See also the PATH.





Pipes and redirection

Very powerful features.

Pipes - Send output of one program to input of other. e.g. Search for all lines in the file that contain "DCU" in any case, except those containing "Computing" in any case, and sort the remaining lines:

cat file | grep -i dcu | grep -iv computing | sort
Backquotes - Capture the output of a program as a string:
echo Current directory is `pwd` and date is `date`
Redirection - Read input from a file, send output to a file.
prog < inputfile > outputfile

cat file | grep -i ca2 > ca2list
cat file | grep -i cae2 > cae2list
Append:
cat morestuff >> ca2list




Filename completion

Start typing filename, hit Esc to complete it.

History


h         history of recent commands (numbered)
!n        replay command number n
!string   replay last command beginning with string
!!        last command

examples
!6 | sort
!ls | grep -v html




UNIX Philosophy

Mac / Windows Philosophy

Note that user interface people say these dialogs are useless. From Donald Norman, The Psychology of Everyday Things, 1988, Ch.5:
Human - Delete all my most important files.
System - Are you sure?
Human - Yes Yes.
System - Are you really sure?
Human - Yes Yes.
System - All your most important files deleted.
Human - Oh damnit.




protections

"ls -l" shows something like:

-rwxr-xr-- 1 userid  groupid  153 Nov  6 1998 filename

-	file (d for directory, l for link/shortcut)
rwx	User (u) can read,write,execute.
r-x	Other members of group (g) can read,execute only.
r--	Other people (o) can read only.

Change with "chmod".
For more see protections (next).




Floppy disk

To mount a floppy disk drive:

volcheck
Then access the floppy files through the path:
/floppy
Note there are no "drives" as in DOS/Windows. Instead everything is mapped to some "virtual" subdirectory of the root / even if you are actually moving around different hardware devices. DOS/Windows could do this too of course:
/C/My Documents/
/A/
See also:
eject