Enter your email address:

Delivered by FeedBurner

shell script

for - Control flow statement in shell scripts

One real important part of programming is to control the flow of the program, you need to be able to repeat some part of the code, jump to another part, etc, depending on the estate of some variables, there are a lot of commands to achieve that, and one of them is for

It can be used directly at the command line like this example using basename

for i in *.jpg; do echo $i $(basename $i .jpg); done

Simple shell script

Maybe most of the readers of this blog do already know about shell scripts, and maybe they know even more than me (which is not difficult), but for those who does not know about it, I will write a little about shell scripts.

A shell script is a sequence of commands -For those coming from DOS is like a .bat file- this command will execute in the sequence they are entered, unless loops, if, do, for, or any other commands like those are used.

Writing the script

Lets go with the classic example, of "Hello World"

Shell Script Automatic Install (create) Apache2 Virtual Servers

When ever you may need to create Virtual Servers for Apache2, you can use this script.

It will create the directory, the config file, and the symbolic link to the /etc/apache2/sites-available in the /etc/apache2/sites-enabled, so will do the job for you.

shell script to backup files using ncftp or scp

With this shell script you can choose at your discretion to use ftp (ncftpput) or ssh (scp) to move your backup files to another server, you can get this script run on a cron job for automatic backup, it also uses tar command to compress your files, before copying them.

Syndicate content

This site is proudly hosted at Bluefur Hosting