imported>mutante mNo edit summary |
imported>mutante mNo edit summary |
||
Line 1: | Line 1: | ||
===The great [[GNU]] Bourne-Again [[Shell]]=== |
|||
#REDIRECT [[Bash]] |
|||
Bash is the shell, or command language interpreter, that will appear in the [[GNU]] [[Operating System]]. |
|||
Bash is an sh-compatible [[shell]] that incorporates useful features from the [[Korn shell]] (ksh) and C shell (csh). |
|||
===Bash Links=== |
|||
*[http://www.gnu.org/software/bash/bash.html Bash GNU home] |
|||
*[http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html Bash Introduction] |
|||
*[http://cnswww.cns.cwru.edu/~chet/bash/bash-intro.html Bash Features] |
|||
*[http://ftp.gnu.org/gnu/bash/ FTP download] |
|||
*[http://www.phptr.com/articles/article.asp?p=441605&seqNum=5&rl=1 The Bourne Again Shell] |
|||
===Useful Keyboard combinations in Bash=== |
|||
*^a = start of line |
|||
=== Operators === |
|||
==== Assignment Operators ==== |
|||
= |
|||
All-purpose assignment operator, which works for both arithmetic and string assignments.Do not confuse the "=" assignment operator with the = test operator. |
|||
=== Arithmetic Operators ==== |
|||
+ |
|||
plus |
|||
- |
|||
minus |
|||
* |
|||
multiplication |
|||
/ |
|||
division |
|||
** |
|||
exponentiation |
|||
% |
|||
modulo, or mod (returns the remainder of an integer division operation) |
|||
+= |
|||
"plus-equal" (increment variable by a constant). let "var += 5" results in var being incremented by 5. |
|||
-= |
|||
"minus-equal" (decrement variable by a constant) |
|||
*= |
|||
"times-equal" (multiply variable by a constant). let "var *= 4" results in var being multiplied by 4. |
|||
/= |
|||
"slash-equal" (divide variable by a constant) |
|||
%= |
|||
"mod-equal" (remainder of dividing variable by a constant) |
|||
==== Logical Operators ==== |
|||
&& |
|||
and (logical) |
|||
|| |
|||
or (logical) |
|||
==== Comparison Operators ==== |
|||
===== Integers ===== |
|||
-eq |
|||
is equal to. if [ "$a" -eq "$b" ] |
|||
-ne |
|||
is not equal to. if [ "$a" -ne "$b" ] |
|||
-gt |
|||
is greater than. if [ "$a" -gt "$b" ] |
|||
-ge |
|||
is greater than or equal to if. [ "$a" -ge "$b" ] |
|||
-lt |
|||
is less than. if [ "$a" -lt "$b" ] |
|||
-le |
|||
is less than or equal to. if [ "$a" -le "$b" ] |
|||
< |
|||
is less than. (within double parentheses) (("$a" < "$b")) |
|||
<= |
|||
is less than or equal to. (within double parentheses). (("$a" <= "$b")) |
|||
> |
|||
is greater than (within double parentheses). (("$a" > "$b")) |
|||
>= |
|||
is greater than or equal to (within double parentheses). (("$a" >= "$b")) |
|||
===== Strings ===== |
|||
= |
|||
is equal to. if [ "$a" = "$b" ] |
|||
== |
|||
is equal to. if [ "$a" == "$b" ] |
|||
!= |
|||
is not equal to. if [ "$a" != "$b" ] |
|||
< |
|||
is less than, in [[ASCII]] alphabetical order |
|||
> |
|||
is greater than, in ASCII alphabetical order |
|||
-z |
|||
string is "null", that is, has zero length |
|||
-n |
|||
string is not "null". |
|||
==== Bitwise Operators ==== |
|||
<< |
|||
bitwise left shift (multiplies by 2 for each shift position) |
|||
<<= |
|||
"left-shift-equal" let "var <<= 2" results in var left-shifted 2 bits (multiplied by 4) |
|||
>> |
|||
bitwise right shift (divides by 2 for each shift position) |
|||
>>= |
|||
"right-shift-equal" (inverse of <<=) |
|||
& |
|||
bitwise and |
|||
&= |
|||
bitwise and-equal |
|||
| |
|||
bitwise OR |
|||
|= |
|||
bitwise OR-equal |
|||
~ |
|||
bitwise negate |
|||
! |
|||
bitwise NOT |
|||
^ |
|||
bitwise [[XOR]] |
|||
^= |
|||
bitwise XOR-equal |
|||
=== Misc Operators === |
|||
, |
|||
comma operator . The comma operator chains together two or more arithmetic operations. All the operations are evaluated (with possible side effects), but only the last operation is returned. |
|||
also see: [[Bash Scripts]] |
|||
[[Category:Linux]] |
|||
[[Category:GNU]] |
Revision as of 13:59, 7 April 2006
The great GNU Bourne-Again Shell
Bash is the shell, or command language interpreter, that will appear in the GNU Operating System.
Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh).
Bash Links
Useful Keyboard combinations in Bash
- ^a = start of line
Operators
Assignment Operators
=
All-purpose assignment operator, which works for both arithmetic and string assignments.Do not confuse the "=" assignment operator with the = test operator.
Arithmetic Operators =
+
plus
-
minus
*
multiplication
/
division
**
exponentiation
%
modulo, or mod (returns the remainder of an integer division operation)
+= "plus-equal" (increment variable by a constant). let "var += 5" results in var being incremented by 5.
-=
"minus-equal" (decrement variable by a constant)
*=
"times-equal" (multiply variable by a constant). let "var *= 4" results in var being multiplied by 4.
/= "slash-equal" (divide variable by a constant)
%= "mod-equal" (remainder of dividing variable by a constant)
Logical Operators
&&
and (logical)
||
or (logical)
Comparison Operators
Integers
-eq
is equal to. if [ "$a" -eq "$b" ]
-ne
is not equal to. if [ "$a" -ne "$b" ]
-gt
is greater than. if [ "$a" -gt "$b" ]
-ge
is greater than or equal to if. [ "$a" -ge "$b" ]
-lt
is less than. if [ "$a" -lt "$b" ]
-le
is less than or equal to. if [ "$a" -le "$b" ]
<
is less than. (within double parentheses) (("$a" < "$b"))
<=
is less than or equal to. (within double parentheses). (("$a" <= "$b"))
>
is greater than (within double parentheses). (("$a" > "$b"))
>=
is greater than or equal to (within double parentheses). (("$a" >= "$b"))
Strings
=
is equal to. if [ "$a" = "$b" ]
==
is equal to. if [ "$a" == "$b" ]
!=
is not equal to. if [ "$a" != "$b" ]
<
is less than, in ASCII alphabetical order
>
is greater than, in ASCII alphabetical order
-z
string is "null", that is, has zero length
-n
string is not "null".
Bitwise Operators
<<
bitwise left shift (multiplies by 2 for each shift position)
<<=
"left-shift-equal" let "var <<= 2" results in var left-shifted 2 bits (multiplied by 4)
>>
bitwise right shift (divides by 2 for each shift position)
>>=
"right-shift-equal" (inverse of <<=)
&
bitwise and
&=
bitwise and-equal
|
bitwise OR
|=
bitwise OR-equal
~
bitwise negate
!
bitwise NOT
^
bitwise XOR
^=
bitwise XOR-equal
Misc Operators
,
comma operator . The comma operator chains together two or more arithmetic operations. All the operations are evaluated (with possible side effects), but only the last operation is returned.
also see: Bash Scripts