Enter the directory where the current script is located (other methods are cloudification !)
Sh_dir =
X = 'echo $0 | grep "^ /"'
If test "$ {x}"; then
Sh_dir = $ (dirname $0)
Else
Sh_dir = $ (dirname 'pwd'/$0)
Fi
CD $ sh_dir
Script pause
Bash-C 'read-N1-P "press any key to continue ..."'
Command for displaying scripts: (the default value is off)
Set-V display command
Set + V disable the display Command Option
Read the configuration file:
The contents of a text.txt file are as follows:
Test = 2 # This is a test.
$ VI text. Sh
#! /Bin/shvalue = 4 value = $ (cat test.txt | grep test = | head-1 | awk-F' = ''{print $2} '| awk-F '# ''{print $1 }') echo $ {value}
$ (XX) is the return value of the XX command. $ {XX} is the XX variable.
Printf "XX \ n \ tyy \ n" is easier to use than Echo. You can control the line feed by yourself.
Echo "XX"> log.txt writes to text
Echo "xx2"> log.txt append to the end of the text
Linux Script Programming (Shell) Introduction: http://blog.csdn.net/compiler_hdz/article/details/575113 (write very complete, but for BASH)
Syntax differences between Dash and Bash: http://www.igigo.net/archives/169
Linux Shell logical operators, logical expressions detailed explanation: http://www.cnblogs.com/chengmo/archive/2010/10/01/1839942.html
Linux awk command Description: http://blog.csdn.net/tianlesoftware/article/details/6278273