210 likes | 472 Views
GNU Compiler Collection (GCC) and GNU C compiler (gcc). tools used to compile programs in Linux. Hello World! program compilation in C. #include <stdio.h> int main() { printf("hello world!<br>"); }. PERL, Python, and bash—script interpreters in Linux. Python is for rapid GUI development
E N D
GNU Compiler Collection (GCC) and GNU C compiler (gcc) • tools used to compile programs in Linux
Hello World! program compilation in C • #include <stdio.h> • int main() • { • printf("hello world!\n"); • }
PERL, Python, and bash—script interpreters in Linux • Python is for rapid GUI development • PERL is for complex jobs and Web pages • bash is for everyday, general-purpose scripting.
Control structures used to develop scripting logic • If...Then...Else statements • Case statements • For loops • While loops • table on page 907
BASH Scripting • Shell scripting provides a way to automate everyday tasks into much simpler commands. • For example, to add 200 users would require running the useradd command 200 times. • The first line of a script identifies the shell or interpreter used to run this script. • Linux uses BASH as the default shell so #! /bin/bash is the first line of BASH scripts.
Any line with a # sign is a comment line. • Use comments to document what a script is doing. • BASH scripting is basically taking several commands into one file in the sequence you wish them executed.
The read statement reads the value of a variable from stdin (standard input). • It fetches input from the keyboard or a source redirected to it. • read a will read a single value from stdin • read a b c will read multiple values on a single line from stdin. • You don’t have to declare variables, just use them • VAR1 = 2 • VAR2 = “Hello, World”
Any arguments to the script are numbered $1, $2, $3, etc and used in the script by their numbers • The echo line displays values. • It can display text: echo “Hello, world” • It can display the contents of a variable: echo VAR1
Pg 921 Lab 5.5
The Read command • the Read command will be used with the While loop to take input from a file. This requires the use of the standard input redirector. Pg 956