ls -l # lists your files in 'long format', which contains the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified
ls -a # lists all files, including hidden files
ln -s <filename> <link> # creates symbolic link to file
touch <filename> # creates or updates your file
cat > <filename> # places standard input into file
more <filename> # shows the first part of a file (move with space and type q to quit)
head <filename> # outputs the first 10 lines of file
tail <filename> # outputs the last 10 lines of file (useful with -f option)
emacs <filename> # lets you create and edit a file
mv <filename1> <filename2> # moves a file
cp <filename1> <filename2> # copies a file
rm <filename> # removes a file
diff <filename1> <filename2> # compares files, and shows where they differ
wc <filename> # tells you how many lines, words and characters there are in a file
chmod -options <filename> # lets you change the read, write, and execute permissions on your files
gzip <filename> # compresses files
gunzip <filename> # uncompresses files compressed by gzip
gzcat <filename> # lets you look at gzipped file without actually having to gunzip it
lpr <filename> # print the file
lpq # check out the printer queue
lprm <jobnumber> # remove something from the printer queue
genscript # converts plain text files into postscript for printing and gives you some options for formatting
dvips <filename> # print .dvi files (i.e. files produced by LaTeX)
grep <pattern> <filenames> # looks for the string in the files
grep -r <pattern> <dir> # search recursively for pattern in directory
varname=value command# defines a variable to be in the environment of a particular subprocess
echo$varname# checks a variable's value
echo$$# prints process ID of the current shell
echo$!# prints process ID of the most recently invoked background job
echo$?# displays the exit status of the last command
exportVARNAME=value # defines an environment variable (will be available in subprocesses)
array[0]= val # several ways to define an array
array[1]= val
array[2]= val
array=([2]=val [0]=val [1]=val)
array(val val val)
${array[i]}# displays array's value for this index. If no index is supplied, array element 0 is assumed
${#array[i]}# to find out the length of any element in the array
${#array[@]}# to find out how many values there are in the array
declare -a # the variables are treaded as arrays
declare -f # uses funtion names only
declare -F # displays function names without definitions
declare -i # the variables are treaded as integers
declare -r # makes the variables read-only
declare -x # marks the variables for export via the environment
${varname:-word}# if varname exists and isn't null, return its value; otherwise return word
${varname:=word}# if varname exists and isn't null, return its value; otherwise set it word and then return its value
${varname:?message}# if varname exists and isn't null, return its value; otherwise print varname, followed by message and abort the current command or script
${varname:+word}# if varname exists and isn't null, return word; otherwise return null
${varname:offset:length}# performs substring expansion. It returns the substring of $varname starting at offset and up to length characters
${variable#pattern}# if the pattern matches the beginning of the variable's value, delete the shortest part that matches and return the rest
${variable##pattern}# if the pattern matches the beginning of the variable's value, delete the longest part that matches and return the rest
${variable%pattern}# if the pattern matches the end of the variable's value, delete the shortest part that matches and return the rest
${variable%%pattern}# if the pattern matches the end of the variable's value, delete the longest part that matches and return the rest
${variable/pattern/string}# the longest match to pattern in variable is replaced by string. Only the first match is replaced
${variable//pattern/string}# the longest match to pattern in variable is replaced by string. All matches are replaced
${#varname}# returns the length of the value of the variable as a character string
*(patternlist)# matches zero or more occurences of the given patterns
+(patternlist)# matches one or more occurences of the given patterns
?(patternlist)# matches zero or one occurence of the given patterns
@(patternlist)# matches exactly one of the given patterns
!(patternlist)# matches anything except one of the given patterns
$(UNIX command)# command substitution: runs the command and returns standard output