BASH Programming " Part 1"

 

Familiarity with GNU/Linux command lines, and familiarity with basic programming concepts is helpful. While this is not a programming introduction, it explains (or at least tries) many basic concepts.
This document tries to be useful in the following situations
  • You have an idea about programming and you want to start coding some shell scripts.
  • You have a vague idea about shell programming and want some sort of reference.
  • You want to see some shell scripts and some comments to start writing your own
  • You are migrating from DOS/Windows (or already did) and want to make "batch" processes.
  • You are a complete nerd and read every how-to available
This HOW-TO will try to give you some hints about shell script programming strongly based on examples.In this section you'll find some little scripts which will hopefully help you to understand some techniques.
  #!/bin/bash          
  echo Hello World
This script has only two lines. The first indicates the system which program to use to run the file.
The second line is the only action performed by this script, which prints 'Hello World' on the terminal.
If you get something like ./hello.sh: Command not found. Probably the first line '#!/bin/bash' is wrong, issue whereis bash or see 'finding bash' to see how sould you write this line.
#!/bin/bash tar -cZf /var/my-backup.tgz /home/me/
"SOON Part 2"

0 comments: