Shell Scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It doesn't matter what you call a file in Linux.  It will be executed as
long as it has execute permission.  You don't need extensions, though a
lot of people do use .sh.  The most important thing to have in a script is
the shell to run as the first line.  This typically looks like:
#!/bin/sh
This tells the system that this script should be interpreted by /bin/sh.
Normally, a number sign is a comment character, but when followed by the
exclamation mark and on the first line of a script, it gets the special
treatment.  If you replaced that line with:
#!/usr/bin/perl
instead, the script would be processed by perl.  It's generally a good
idea to give the complete path.

As to your second question, parameters are called $1, $2, and so forth in
shell scripts.  $0 is the command name, so you can tell what a command was
called by the user.  Hope this helps.





[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux