Home  >  Article  >  Operation and Maintenance  >  What is the difference between sh and bash in Linux SHELL

What is the difference between sh and bash in Linux SHELL

王林
王林forward
2023-06-03 16:07:031612browse

What is SHELL?
The Chinese meaning of shell is shell, which is actually more similar to the shell of our core. In short, as long as the interface that can operate the application program can be called SHELL. The narrow sense of shell refers to command line software, and the broad sense of SHELL includes graphical interfaces.

SHELL VERSION
In the book Niao Ge’s Private Kitchen, the UNIX version and numerous SHELL versions are introduced.
As early as the UNIX era, there were many developers, so there were many versions of shells depending on the developers, such as sh, C SHell, K SHell, and TCSH, etc. Each shell had its own characteristics. Of course, there is also our bash. The bash shell is an enhanced version of the Bourne Shell and is also developed based on the GNU architecture.

The difference between sh and bash
Because bash is an enhanced version of sh, if the sh command does not work during our daily field operations, we should use bash.
For example, if we use the addition and subtraction of numbers
There are several different versions.

#! /bin/bash
no1=4
no2=5
let no1++
let result=no1+no2
echo $result
result=$[no1+no2]
echo $result
result=$[$no1+5]
echo $result
result=$((no1+50))
echo $result


如果使用sh则输出
test3.sh: 4: test3.sh: let: not found
test3.sh: 5: test3.sh: let: not found
$[no1+no2]
$[4+5]
54

You can see that sh not only does not support multiple commands, but also has many small differences.
So in fact we should use bash more, that is./xx.sh, the premise is to modify the permissions, chmod a x xx.sh.

The above is the detailed content of What is the difference between sh and bash in Linux SHELL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete