Shell Script

From BC$ MobileTV Wiki
(Redirected from Bash)
Jump to: navigation, search

A Shell Script is a system-level control program which enables certain operations to be automated.


The "shebang" or "opening header" is a directive which should appear at the top of a particular type of Shell script and location. It should be any ONE of the following:

#!/bin/sed -f
#!/usr/awk -f




./ [ARGS]

Run shell script As root:

sudo sh [ARGS]


locate <something>


locate tomcat

list all known files/folders which contain the name "tomcat"


ps ax | grep <something>


ps ax | grep VRD

list running processes which start with "VRD"




nohup <something>


nohup VRD-proxy &

run VRD-Proxy application with "no hang-ups" (even after shell closes) [3]


Setup a cleanup function to be triggered upon script exit:

 __cleanup ()
    -f "MyProcess.lock"  && rm "MyProcess.lock"
 # ...
 # bunch of other commands and stuff
 # ...
 trap __cleanup EXIT


Environment Variables




External Links

refs with no name must have content


  1. Headers in shell scripts: t
  2. Tab separated values in awk:
  3. wikipedia: nohup
  4. Bash Guide for Beginners -- Chapter 12. Catching signals:
  5. Can a shell script set environment variables of the calling shell?:
  6. Shell scripting with most common use-cases:
  7. Top 10 Best Cheat Sheets and Tutorials for Linux / UNIX Commands:
  8. Bash Cheat Sheet:
  9. Original cheat sheet:
  10. How to Pass Arguments to Shell Script:
  11. How to pass command-line parameter to shell script?:
  12. Shell Scripts with Multiple Arguments:
  13. if else bash script:
  14. Bash -- run command before a script exits?:
  15. Use the Bash trap Statement to Clean Up Temporary Files:
  16. How "Exit Traps" Can Make Your Bash Scripts Way More Robust And Reliable:
  17. How to redirect standard error in bash:
  18. BASH Shell -- How To Redirect stderr To stdout (redirect stderr to a File ):
  19. Input/Output Redirection in the Shell:

See Also

MySQL | FTP | Cloud Computing | Batch Script | TCL