Saturday, March 19, 2011

How to run shell scripts like UNIX commands?

By including the script path in the environment variable PATH, you can run your shell script just like any UNIX command. i.e., irrespective of your current location you can run the script with just script name.

Example:
volcano@volcano-laptop:~$ PATH=$PATH:/home/volcano/shellscript
volcano@volcano-laptop:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:.:/home/volcano/shellscript
volcano@volcano-laptop:~$ hello.sh
Hello World!

3 comments:

  1. Sujay,

    Include find/searche related unix command and shell script.

    Most of the people using these stubs frequently.

    Like how to search a string in a very large text file using vi editor.

    ReplyDelete
  2. Hi Sujay,

    You make blogging seem easy. The total look of your site is amazing.

    Thank & Regards
    Elena Lauren

    ReplyDelete