Problems encountered in Bash programming:
First, it is recommended that you write bash under Linux, and if you want to write bash with Windows, you should pay special attention to several issues:
First: Coding problems, encoded with utf-8,
Second: line break problem, Windows is the end of carriage return (CRLF), Linux is the end of line break (LF)
Third: Use Utf-8 without BOM.
These three points are considerations for writing bash under Windows.
As for the grammar, I do not say more on this side, I am also the first to write bash, grammar basically nothing to say, there is a year of programming based on all can understand.
Http://pan.baidu.com/s/1o6C1rnW,
Share a bash clip. This is obtained from the Maven Nexus, and its function is to get the absolute path
# Resolve The true real path without any sym links.
Changed=true
While ["x$changed"! = "X"]
Do
# Change spaces to ': ' So the ' tokens can be parsed.
Safescript= ' echo $SCRIPT | Sed-e ' s;;:; G '
#echo "script path is:[$SCRIPT]"
#echo "Safescript path is:[$SAFESCRIPT]"
# Get The real path to this script, resolving any symbolic links
Tokens= ' echo $SAFESCRIPT | Sed-e ' s;/;; G '
#echo "TOKENS path is:[$TOKENS]"
Realpath=
For C in $TOKENS; Do
# change any ': ' In the token ' back to a space.
C= ' echo $C | Sed-e ' s;:;; G '
Realpath= "$REALPATH/$C"
# If Realpath is a sym link, resolve it. loop for nested links.
While [-H ' $REALPATH "]; Do
ls= "' Ls-ld" $REALPATH "'"
link= "' Expr ' $LS": ' .*-> \ (. *\) $ ' "
If expr "$LINK": '/.* ' >/dev/null; Then
# LINK is absolute.
Realpath= "$LINK"
Else
# LINK is relative.
Realpath= "' DirName" $REALPATH "'" "/$LINK"
Fi
Done
Done
If ["$REALPATH" = "$SCRIPT"]
Then
Changed= ""
Else
script= "$REALPATH"
Fi
Done
# The current directory to the location of the script
CD "' DirName" $REALPATH "'"
Realdir= ' pwd '
Bash Basic Syntax _ download Link: http://yun.baidu.com/share/link?shareid=2510088394&uk=4043945255
A few examples of bash:
1, automatic packaging. Http://pan.baidu.com/s/1bniv5W7
2. The Linux service runs the Java shell. http://yun.baidu.com/share/link?shareid=3338177448&uk=4043945255
3. Linux runs Java commands, including configuration of environment variables, setting of JVM parameters. http://yun.baidu.com/share/link?shareid=3334612191&uk=4043945255
&& Another Windows run Java command, with the same functionality as 3 http://yun.baidu.com/share/link?shareid=3335077510&uk=4043945255
Linux Bash programming