| what |
name |
description |
example |
| # |
Comment |
A Comment to the end of line |
# hacked 7/25/2006 dvl |
| & |
Ampersand |
Push into the background |
myprog & |
| ! |
Bang |
Negation of the next thing |
! -f ~/.bash_profile |
| . cmd |
Dot |
Execute cmd in the same shell, without spawning/forking. |
. ~/myaliases |
| ' ... ' |
Single Quotes |
Do not interpret variables inside |
fish=flounder echo 'I like $fish.'
Produces: I like $fish. |
| " ... " |
Double Quotes |
Do interpret variables inside |
fish=flounder echo "I like $fish."
Produces: I like flounder. |
| ` ... ` |
Back Tick |
Return the output of commend inside as a value |
date=`date` echo "The date is $date"
Produces: The date is Tue Jul 25 13:30:30 EDT 2006
-- or --
pg_installed=`grep -c postgres /etc/passwd` |
| ~ |
Tilda |
Alias for my Home Directory
Same as $HOME |
ls ~/bin |
| ~fred |
Tilda Fred |
Alias for Fred's Home Directory |
ls ~fred/bin |
| /dev/null |
Sink |
Nowheres land |
wc *.lst 2>/dev/null |
| cmd1 | cmd2 |
Pipe |
Pipe the output of cmd1 as input to cmd2 |
ps -ef | grep dlink |
| cmd > file |
Redirect STDOUT |
Put output of cmd into file |
grep -i matrix nieson.fil > matrix.titles |
| cmd 2> file |
Redirect STDERR |
Put errors from cmd into file |
find / -name "sheep*" 2> /dev/null |
| <<EOF |
Here Document. |
End of File Marker |
herer |
| cmd >> file |
Append STDOUT |
Put output of cmd on the end of file |
grep -i casper nieson.fil >> matrix.titles |
| cmd < file |
Redirect STDIN |
cmd takes input from file |
tr 'A-Z' 'a-z' < phonebk.txt
|
| 2>&1 |
STDERR into STDOUT |
Combine STDERR into STDOUT as one I/O channel. |
gen_summary > log 2>&1
-- or --
myprog 2>&1 | more |
| $0 |
Prog |
Name of command executing |
cat >> hello.sh
echo $0
CTRL-D
./hello.sh
Hello, World.
./hello.sh
|
| $1 |
First Argument |
First thing on the command line after the program name |
if [[ -z $1 ]] ; then
echo you must give name.
fi |
| $2 |
Second Argument |
Second thing on the command line after the program name |
if [[ -z $2 ]] ; then
echo you must give type.
fi |
| $* |
All Argument |
Same as $1 $2 $3 ... |
for f in $*; do
wc $f
done |
| -d |
Is a Directory? |
File exists and it is a directory. |
if [[ -d ~/video/bin ]] ; then
. ~/video/bin/aliases
fi |
| -f |
Is a File? |
File exists and it is a regular file. |
|
| -r |
Is Readable? |
You have read permission on file. |
|
| -w |
Is Writable? |
You have write permission on file. |
|
| -x |
Is Executable? |
you have execution permission on file. |
|
| ~/.bash_profile |
User Login Profile |
Gets executed each time you log in. (Normally). Sometimes it is simple
~/.profile. |
|
| CTRL-C |
BREAK |
Interrupt running process |
find / -name "sheep*"
CTRL-C |
| CTRL-D |
EOF |
Used to end input |
cat > notes
Remember to talk about
Control Keys.
CTRL-D |
| CTRL-Q |
Un Pause Screen |
Undoes a CTRL-S |
|
| CTRL-S |
Pause Screen |
Pauses screen output |
ls -l
CTRL-S
CTRL-Q |
| CTRL-Z |
SUSPEND |
Suspend a process |
emacs notes
CTRL-Z
bg
|