Red Hat NETSCAPE MANAGEMENT SYSTEM 6.0 - COMMAND-LINE Instrukcja Użytkownika Strona 35

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 60
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 34
35
Help File Library: Bash Scripting Cheat Sheet
Written By: ph34r
A quick cheat sheet for programmers who want to do shell scripting. This is not intended to teach
programming, etc. but it is intended for a someone who knows one programming language to
begin learning about bash scripting.
Basics
All bash scripts must tell the o/s what to use as the interpreter. The first line of any script should
be:
#!/bin/bash
You must make bash scripts executable.
chmod +x filename
Variables
Create a variable - just assign value. Variables are non-datatyped (a variable can hold strings,
numbers, etc. with out being defined as such).
varname=value
Access a variable by putting $ on the front of the name
echo $varname
Values passed in from the command line as arguments are accessed as $# where #= the index of
the variable in the array of values being passed in. This array is base 1 not base 0.
command var1 var2 var3 .... varX
$1 contains whatever var1 was, $2 contains whatever var2 was, etc.
Built in variables:
Variable Use
$1-$N Stores the arguments (variables) that were passed
to the shell program from the command line.
$? Stores the exit value of the last command that was
executed.
$0 Stores the first word of the entered command (the
name of the shell program).
$* Stores all the arguments that were entered on the
command line ($1 $2 ...).
"$@" Stores all the arguments that were entered on the
command line, individually quoted ("$1" "$2" ...).
Przeglądanie stron 34
1 2 ... 30 31 32 33 34 35 36 37 38 39 40 ... 59 60

Komentarze do niniejszej Instrukcji

Brak uwag