Name:
Location: United States

Tuesday, March 25, 2008

BASH script quick reference

1. Special character
  • ; --Command separator
  • ;; --double terminator in case ....esac
  • # -- comment
  • . -- equivalent to source command. e.g. Note: dot has other meanings as well.
    . data-file  # source data-file
  • "STRING" --partial quoting preserve most of the special characters within STRING
  • 'STRING' -- full quoting preserves all special characters within STRING
  • , -- comma separator ,links together a series of arithmetic operations. All are evaluated, but only the last one is returned.
  • \-- escape
  • ` -- command substitutions. `command` makes available the output of command for assignment to a variable
  • : -- null command=NOP , :=true
  • ! -- invert/negate/reverse the sense of a test or exit status[bang]
  • () -- command group,(a1=1,b=2), or array initialization
  • {a,b,c}--brace expansion,eg. cat {file1,file2,file3}>combined_file,eg. cp file22.{txt,backup}
  • {a..z} -- extended brace expansion. echo {a..z} #a,b,c,d....z
  • [] -- test expression between []
  • [[]]-- test.


2.

0 Comments:

Post a Comment

<< Home