Six Flashcards
locate the binary file of a command
whereis command
short description of a command
whatis command
to repeat most recent command
!!
to turn on a environmental variable
set -o variable_name
set +o variable_name will turn it off
shopt -s optionName : enable it
shopt -u optionName: disable it
what is the if expression
if condition then elif condition then else fi
grep format
grep pattern file
date
date +Format
positional parameters
$0 is the script itself $1 is the first argument $2 the second . after $9 it must be written as ${} $# is the total number of inputs
[ -z “string” ]
the length of the string is nonzero
case expression
case $var in var1) ;; var2) ;; *) ;; esac
translate string
tr [option] set1 set2
another way to avoid using tr
case $input in
[Ss][Oo])…….
Third way to turn on case-insensitiveness
shopt -s nocasematch
case $opt in
shopt -u nocasematch
for loop
for var in item1 item2
do
….
done
for loop (C heritage)
for (( EXP1; EXP2; EXP3))
do
done