Flow Control

Tux

This is post 12 of 19 in the series “[ Shell Scripting ]” The Bourne/bash shell supports a variety of conditionals, loops and other flow control operations. You’ll use these often. if The if statement is a simple conditional. Its syntax is: if condition ; then commands [elif condition ; then commands]… [else commands] fi …

Shell Differences

This is post 14 of 19 in the series “[ Shell Scripting ]” Differences in the Bourne and bash Shell Scripting Environments Major differences between Bourne and bash at http://www.faqs.org/docs/bashman/bashref_122.html: (emphasis added) Bash implements the ! keyword to negate the return value of a pipeline. Very useful when an if statement needs to act only …

String Functions

This is post 15 of 19 in the series “[ Shell Scripting ]” String Functions: echo, cut, paste, tr, sed, sort, grep and awk Some programming languages, for instance perl, have terrific string-handling functions built right in. Bourne/Bash isn’t as comprehensive as perl, but it does have a basic set of functions for cutting, pasting, …

awk

This is post 16 of 19 in the series “[ Shell Scripting ]” awk Much like sed, awk searches for patterns in text. Then it performs any of a wide variety of actions. What makes awk different is how it deals with text files. It treats lines of text as records (tuples) in a database; …

xargs

This is post 17 of 19 in the series “[ Shell Scripting ]” xargs Take a look at this page at www.ss64.com dealing with xargs. As always, look at the Wikipedia entry at http://en.wikipedia.org/wiki/Xargs UnixReview.com “Using the xargs Command” at http://www.unixreview.com/documents/s=8274/sam0306g/ The Linux Documentation Project: Complex Commands at http://tldp.org/LDP/abs/html/moreadv.html SysAdmin to SysAdmin: bring out your …

Power Tools

This is post 18 of 19 in the series “[ Shell Scripting ]” Fix Windows Line Endings from the Command Line Use the dos2unix command to change Windows line endings to Unix line endings. To replace an existing file with a “fixed” file, type: dos2unix file_name.txt To create a new fixed version of the file, …

Exercise 3

This is post 19 of 19 in the series “[ Shell Scripting ]” Now it’s time to assemble the tinker-toys you’ve been learning to use. 1. Create a new script named ~/bin/userlogin. 2. Create two log files: ~/success.log and ~/failure.log 3. Create a password file, ~/userpasswords, and populate it with at least one tab-separated user …

Example : sql.shl

: #!/bin/sh # # FILE NAME…: SQL.shl # OBJECT NAME.: SQL # OBJECT TITLE: Shell Script # RELEASE…..: 6.0 # PRODUCT…..: Finance # USAGE…….: # # DESCRIPTION: # Unix bourne shell script to execute SQL # Script (fzrlegi.sql) from ob Submission and handle process output # and messages in accordance with the Job Submission methodology. …