What is Shell Scripting?

In many Linux distributions, you can happily start coding right on your command line. That code often looks something like this…

#!/bin/bash
TOTAL=0
for i in {1..999}
do
    if (( $i % 3 == 0 || $i % 5 == 0 ))
    then
        let "TOTAL = TOTAL + i"
    fi
done
echo $TOTAL

I technically learned how to use command lines the first time I typed lines of AppleBASIC into our family computer back on the farm. But it was really in high school when I started to learn the glories of piping commands together to take advantage of what it can really do.

In Windows, there used to be only DOS Batch scripting, but now there’s Powershell, which is both more powerful (as the name would imply) and more readable. For example:

# PE1.psl
$total = 0
for ($i = 1; $i -lt 1000; $i++) {
	if (($i % 3 -eq 0) -or ($i % 5 -eq 0)){
		$total = $total + $i
	}
}
Write-Host $total