Shell Script Study Resources

Check out this site, excellent reference for any shell script syntax.


UNIX-1.11 zip, basename, mktemp, script and rcs commands

Make sure to subscribe to my channel for more videos on UNIX, Perl and SQL.
twitter: @fuzicast

zip -r file1 file2 file3 – zip and compress files, recursively
unzip – unzip a zip file
rmdir dirname – remove empty directory
basename fullpath – returns the file or directory name
dirname fullpath – returns the directory
mktemp – creates a temporary file and outputs temp filename
factor number – list the factors of a number
script -a script.out – starts recording your output screen, ctrl+D to stop recording
kill %% – kills previous command
sudo apt-get install rcs – to install linux revision control system (RCS)
mkdir RCS – create a directory called RCS to store all versions of file
ci – checks in a file, file is not readable until checked out
ci -u – checks in a file, file is visible for others to read
co -l – checks out a file, holds the lock.
co -lr1.1 – checks out a version of file, holds the lock
rcsdiff – compares current file with latest checked in version
rcsdiff -r1.1 -r1.2 – compares version 1.1 and 1.2
which command – tells you where such command resides in
locate keyword – searches for files or paths that contains keyword (that are accessible to you)

UNIX-1.10 Customize Command Prompt

Make sure to subscribe to my channel for more videos on UNIX, Perl and SQL.
twitter: @fuzicast

set -o vi – puts your command prompt into VI mode, allows you to execute VI commands
/command – search for command history, n for next match found, N for previous match found
PS1 – variable that holds text of your prompt
PS1=”\H” – displays host name
PS1=”\s” – name of shell
PS1=”\u” – current username
PS1=”\w” – current working directory
PS1=”\@” – current time
PS1=”[\\u@\\H \\W \\@]\\$” – try this
PS1=”\e[x;ym$PS1\e[m” – \e[ starts the color mode, x;ym specifys color, \e[m ends color mode. x;y can be 0;30 to 0;37
case $(id -u) in
0) PS1=”${PS1}# “;;
*) PS1=”${PS1}$ “;;
alias name=”command -options” – creating alias/shortcut commands
alias vi=’vim’
alias ls=’ls -F’
alias ll=’ls -l’
alias la=’ls -la’
alias cp=’cp -ip’
alias mv=’mv -i’