In Debian and Ubuntu,/bin/sh is directed to dash by default. This is a shell different from Bash. It mainly appears to execute scripts instead of interactions, <br/> it is faster, but has fewer functions than Bash. The syntax strictly complies with the POSIX standard. The following briefly lists the issues that need to be paid attention to when migrating from Bash to dash. define a function <br/> Bash: The function is a keyword in bash <br/> IGI @ Gentoo ~ $ Foo () {echo $0 ;}< br/> IGI @ Gentoo ~ $ Foo <br/>/bin/bash <br/> IGI @ Gentoo ~ $ Function foo2 () {echo $0 ;}< br/> IGI @ Gentoo ~ $ Foo2 <br/>/bin/bash <br/> DASH: The function keyword is not found in Dash. <br/> $ Foo () {echo $0 ;} <br/> $ Foo <br/> dash <br/> $ function foo2 () {echo $0 ;}< br/> DASH: syntax error: "(" unexpected <br/> 2. select VaR in list; do command; done <br/> Bash: <br/> IGI @ Gentoo ~ is supported ~ $ Select input in a B <br/> DO <br/> case $ input in <br/> A) <br/> echo 'input: a' <br/> Break <br/>; <br/> B) <br/> echo 'input: B '<br/> Break <br/>; <br/> esac <br/> done <br/> 1) A <br/> 2) B <br/> #? 1 <br/> input: A <br/> IGI @ Gentoo ~ $ Echo $0 <br/>/bin/bash <br/> DASH: not supported. Alternative method: While + read + case <br/> menu () {echo-n "1) A;/N2) B/n> ";} <br/> menu <br/> while read input <br/> DO <br/> case $ input in <br/> 1) <br/> echo 'A' <br/> Break <br/>; <br/> 2) <br/> echo 'B' <br/> Break <br/>; <br/> *) <br/> menu <br/> continue <br/>; <br/> esac <br/> done <br/> 3. echo {0 .. 10} <br/> Bash: {n .. m} expand <br/> IGI @ Gentoo ~ $ Echo $0 <br/>/bin/bash <br/> IGI @ Gentoo ~ $ Echo {0 .. 10} <br/> 0 1 2 3 4 5 6 7 8 9 10 <br/> DASH: not supported. Alternative method, use seq External commands <br/> $ echo $0 <br/> dash <br/> $ echo {0 .. 10} <br/> {0 .. 10} <br/> $ echo 'seq 0 10' <br/> 0 1 2 3 4 5 6 7 8 9 10 <br/> 4. here string <br/> Bash: supported here string <br/> IGI @ Gentoo ~ $ Cat <"string" <br/> string <br/> IGI @ Gentoo ~ $ Echo $0 <br/>/bin/bash <br/> DASH: not supported. Alternative method: here documents <br/> $ echo $0 <br/> dash <br/> $ cat <"string" <br/> DASH: syntax error: redirection unexpected <br/> $ cat <EOF <br/> string <br/> 5.> & Word redirection standard output and standard error <br/> Bash: When word is not a number, & Word becomes a redirection standard error and the standard output to the file word, common usage> &/dev/null <br/> IGI @ Gentoo ~ /Test $ ls <br/> A <br/> IGI @ Gentoo ~ /Test $ ls a B <br/> ls: cannot access B: no such file or directory <br/> A <br/> IGI @ Gentoo ~ /Test $ ls a B> & amp;/dev/null <br/> IGI @ Gentoo ~ /Test $ ls a B>/dev/null 2> & 1 <br/> IGI @ Gentoo ~ /Test $ echo $0 <br/>/bin/bash <br/> DASH:> & word, word does not support non-numbers. Alternative method:> word 2> & 1; common usage>/dev/null 2> & 1 <br/> $ echo $0 <br/> dash <br/> $ ls a <br/> A <br/> $ ls a B <br/> ls: cannot access B: no such file or directory <br/> A <br/> $ ls a B> &/dev/null <br/> DASH: syntax error: bad FD number <br/> $ ls a B>/dev/null 2> & 1 <br/>$ <br/> 6. array <br/> Bash: supports arrays and bash4 supports arrays. <br/> IGI @ Gentoo ~ /Test $ echo $0 <br/>/bin/bash <br/> IGI @ Gentoo ~ /Test $ array = (a B C) <br/> IGI @ Gentoo ~ /Test $ echo $ {array [2]} <br/> C <br/> DASH: arrays are not supported. Alternative methods, use the variable name + serial number to achieve similar results <br/> $ for I in a B C <br/> DO <br/> id = $ ($ {ID: =-1} + 1 )) <br/> eval array _ $ id = $ I <br/> done <br/> $ echo $ {array_1} <br/> B <br/> $ echo $0 <br/> dash <br/> very painful, it is not recommended to use this function unless otherwise. <br/> 7. substring extension <br/> Bash: $ {parameter: offset: length}, $ {parameter: Offset} <br/> IGI @ Gentoo ~ /Test $ string = 'hello' <br/> IGI @ Gentoo ~ /Test $ echo $ {string: 1: 3} <br/> ell <br/> IGI @ Gentoo ~ /Test $ echo $ {string: 1} <br/> ello <br/> IGI @ Gentoo ~ /Test $ echo $0 <br/>/bin/bash <br/> DASH: not supported. Alternative method: replace <br/> $ string = 'hello' <br/> $ expr substr "$ string" 2 3 <br/> ell <br/> $ echo "$ string" | cut-c2-4 <br/> ell <br/> $ expr substr "$ string" 2 "$ {# string}" <br/> ello <br /> $ echo "$ string" | cut-C2-<br/> ello <br/> $ echo $0 <br/> dash <br/>$ <br/> 8. case-sensitive conversion <br/> Bash: $ {parameter ^ pattern}, $ {parameter ^ pattern}, $ {parameter, pattern}, $ {Par Ameter, pattern} <br/> IGI @ Gentoo ~ /Test $ string = "abcabc" <br/> IGI @ Gentoo ~ /Test $ echo $ {string ^} <br/> abcabc <br/> IGI @ Gentoo ~ /Test $ echo $ {string, ,}< br/> abcabc <br/> IGI @ Gentoo ~ /Test $ echo $ {string ^ B} <br/> abcabc <br/> IGI @ Gentoo ~ /Test $ echo $0 <br/>/bin/bash <br/> DASH: not supported. Alternative method: conversion using TR/SED/awk and other external commands <br/> $ string = 'abc' <br/> $ echo "$ string" | tr '[A-Z]'' [A-Z] '<br/> abcabc <br/> $ echo "$ string" | tr' [A-Z] ''[A-Z] '<br/> abcabc <br /> $ echo "$ string" | SED's/B // U &/G' <br/> abcabc <br/>$ <br/> 9. process replacement <(command),> (command) <br/> Bash: Process replacement <br/> IGI @ Gentoo ~ $ Diff <(SEQ 3) <(SEQ 4) <br/> 3a4 <br/> 4 <br/> IGI @ Gentoo ~ $ Echo $0 <br/>/bin/bash <br/> DASH: not supported. Alternative method: transfer through temporary files <br/> $ diff <(SEQ 3) <(SEQ 4) <br/> DASH: syntax error: "(" unexpected <br/> $ seq 3> tmp1 <br/> $ seq 4> tmp2 <br/> $ diff tmp1 tmp2 <br/> 3a4 <br/> 4 <br/> $ echo $0 <br/> dash <br/>$ <br/> 10. [string1 = string2] and [string1 = string2] <br/> Bash: both are supported <br/> IGI @ Gentoo ~ $ ['A' = 'a'] & Echo 'equal' <br/> equal <br/> IGI @ Gentoo ~ $ ['A' = 'a'] & Echo 'equal' <br/> equal <br/> IGI @ Gentoo ~ $ Echo $0 <br/>/bin/bash <br/> DASH: only <br/> $ ['A' = 'a'] & Echo 'equal' <br/> equal <br/> $ ['A' =' a'] & Echo 'equal' <br/> [: 2: A: Unexpected operator <br/> $ echo $0 <br/> dash <br/>$ <br/> 11. [[enhanced version test <br/> Bash: supports [[] and provides powerful functions such as regular expression matching. <br/> IGI @ Gentoo ~ $[['Xyz123 '= ~ XYZ [0-9] +] & Echo 'equal' <br/> equal <br/> IGI @ Gentoo ~ $ Echo $0 <br/>/bin/bash <br/> DASH: [[] not supported. Alternative method, use external commands <br/> $ [['xyz123' = ~ XYZ [0-9] +] & Echo 'equal' <br/> DASH :[[: not found <br/> $ echo 'xyz123 '| grep-Q 'xyz [0-9]/+' & Echo 'equal' <br/> equal <br/> $ echo $0 <br/> dash <br/>$ <br/> 12. for (expr1; expr2; expr3); Do list; done <br/> Bash: Supports for loops in C language format <br/> IGI @ Gentoo ~ $ For (I = 0; I <= 3; I ++); Do echo "$ I "; done <br/> 0 <br/> 1 <br/> 2 <br/> 3 <br/> IGI @ Gentoo ~ $ Echo $0 <br/>/bin/bash <br/> DASH: The for format is not supported. The alternative method is while + $ (expression )) implement <br/> $ I = 0 <br/> $ while ["$ I"-le 3] <br/> DO <br/> echo "$ I" <br/> I = $ (I + 1 )) <br/> done <br/> 0 <br/> 1 <br/> 2 <br/> 3 <br/> $ echo $0 <br/> dash <BR/>$ <br/> 13. let command and (expression) <br/> Bash: a built-in let Command is provided. The (expression) mode is also supported. <br/> IGI @ Gentoo ~ $ I = 0 <br/> IGI @ Gentoo ~ $ Let I ++ <br/> IGI @ Gentoo ~ $ Echo $ I <br/> 1 <br/> IGI @ Gentoo ~ $ (I ++) <br/> IGI @ Gentoo ~ $ Echo $ I <br/> 2 <br/> IGI @ Gentoo ~ $ Echo $0 <br/>/bin/bash <br/> DASH: not supported. Alternative method: $ (expression )) or use external commands for calculation <br/> $ I = 0 <br/> $ I = $ (I + 1 )) <br/> $ echo $ I <br/> 1 <br/> $ echo $0 <br/> dash <br/>$ <br/> 14. $ (expression) <br/> Bash: supports ID ++, id --, ++ ID, and -- ID to the expression <br/> IGI @ Gentoo ~ $ I = 0 <br/> IGI @ Gentoo ~ $ Echo $ (I ++) <br/> 0 <br/> IGI @ Gentoo ~ $ Echo $ I <br/> 1 <br/> IGI @ Gentoo ~ $ Echo $ (++ I) <br/> 2 <br/> IGI @ Gentoo ~ $ Echo $ I <br/> 2 <br/> IGI @ Gentoo ~ $ Echo $0 <br/>/bin/bash <br/> DASH: not supported +, --, alternative method: ID + = 1, ID-= 1, id = ID + 1, id = ID-1 <br/> $ I = 0 <br/> $ echo $ (I ++) <br/> DASH: arithmetic expression: expecting primary: "I ++" <br/> $ echo $ I; I =$ (I + 1 )) <br/> 0 <br/> $ echo $ I <br/> 1 <br/> $ echo $ (I + = 1 )) <br/> 2 <br/> $ echo $ I <br/> 2 <br/> $ echo $0 <br/> dash <br/> $