General BASH tips
eharetea

This includes some terminal key commands, bracing, basic math, and creating variables.

A few things about BASH.

Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Wednesday July 30th, 2008 05:11 PM

QUICK TERMINAL KEY COMMANDS:

ctrl + a  begining of line
ctrl + e end of line
ctrl + d delete

BRACING
cp noise.vfl{,-old}
same as:
cp noise.vfl noise.vfl-old

noise.vfl{-old,} 
same as
mv noise.vfl-old noise.vfl

makes archive1.vfl archive2.vfl etc...
touch archive{1,2,3,4,5}.vfl
the last comma would make the last file created be archive.vfl
touch archive{1,2,3,4,5,}.vfl

mv $file ${file}X

MULTIPLE COMMANDS
the second one will not continue to the following command if the first fails
cd $HOME; ls; cd ../
cd $HOME && ls && ../

SILENT COMMANDS
touch itworked &> /dev/null

SETTING VARIABLES TO COMMANDS
name ="Dan"
name=`echo $name | tr '[a-z]' '[A-Z]'`
echo $name

VARIABLES
DAN=$1
local variables:
local DAN=$1

EXPR
i=1
expr $i + 1
2

WC
wc -l infile
number of lines

wc -c infile
number of characters

wc -w infile
number of words

DIFF
difference between files
diff ship.ifd ship2.ifd


ls -l --sort=time -r
sorts by time