Basic Linux Shell Scripting Concepts

|
Rather Have Fast and Secure Remote
Control?
|
Input Parameters
Shell scripts can also accept input parameters. This allows you to build a multi-function script that can perform different actions each time it is executed. Input parameters are easy to use. They are automatically store in variables that represent their ordinal position when specified. For example, the first input parameter can be referenced as $1, the second as $2 and so on. Consider the following example.
#!/bin/bash
echo You told me to say $1
Save this script as [talk] and then run the following
[./talk Hello]
Looping
Looping allows the repeated execution of a section of code. This can be used to parse though repeated values, or to add multiple entries to a file. The following is the syntax of a loop.
while test; do
repeated code
loop
The keyword [break] can be used anywhere in the code to exit the loop at any point. This is typically found inside a nested if. Next is an example of a loop that counts to 10, printing the output each time.
#!/bin/bash
ctr=1
while ctr <=10; do
echo value is $ctr
$ctr=$ctr+1
loop
Next post in Linux:
Basic Linux Shell Scripting Part 2
Next post in Programming:
Basic Linux Shell Scripting Part 2
Previous post in Linux:
Configuring a Linux Newsgroup (NNTP) Server
Previous post in Programming:
SQL and T-SQL
All Tutorials by Category:
- CCDA Study Guide
- CCNA Study Guide Chapter 01
- CCNA Study Guide Chapter 02
- CCNA Study Guide Chapter 03
- CCNA Study Guide Chapter 04
- CCNA Study Guide Chapter 05
- CCNA Study Guide Chapter 06
- CCNA Study Guide Chapter 07
- CCNA Study Guide Chapter 08
- CCNA Study Guide Chapter 09
- CCNA Study Guide Chapter 10
- CCNA Study Guide Chapter 11
- CCNA Study Guide Chapter 12
- Cognos
- Computer Hardware
A
C
D
E
F
G
H
I
L
M
N
Entire site Copyright © 1999-2007 2000Trainers.com, all rights reserved.
Content on this site may not be copied or reproduced in any way without permission.


