More UNIX


.cshrc / .bashrc

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


.login / .profile

Runs once, when you log in.
Like AUTOEXEC.BAT on DOS.
Can call a shell script in here.



DCU Linux - How to change the prompt

edit .bashrc

Example:

PS1='\W> '

See:



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 student > studentlist
cat file | grep -i staff   > stafflist
Append:
cat morestuff >> studentlist




Filename completion

Start typing filename, hit special key 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 often ignored.
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.

Compare with UNIX:

Human - Delete all my most important files.
System - (Silence.)
Human - Oh damnit.



Command-line on Mac / Windows