- [Shell ](#shell-)
- [ Shell ](#-shell-)
- [Shell](#shell)
- [ Shell](#-shell)
- [Shell Hello World](#shell--hello-world)
- [Shell ](#shell-)
- [Shell ](#shell-)
- [Shell ](#shell-)
- [Shell ](#shell-)
- [Shell ](#shell-)
- [Shell ](#shell-)
- [](#)
- [](#)
- [](#)
- [](#)
- [](#)
- [](#)
- [shell](#shell)
- [if ](#if-)
- [for ](#for-)
- [while ](#while-)
- [shell ](#shell-)
- [](#)
- [](#)
- [](#)
# Shell
## Shell
### Shell
Shell
Shell Linux Shell shell
LinuxShellPython
ShellITshellPython webShell
shell Shell

### Shell
ShellLinux
W3Cschool Shell

### Shell Hello World
HelloWordshellShell Hello World
(1) helloworld.sh :`touch helloworld.sh` shshShell php shell php
(2) `chmod +x helloworld.sh`
(3) vim helloworld.sh`vim helloworld.sh`(vim ------>----->------>i-----> ------->Esc----->:wq/q! wqq!)
helloworld.sh
```shell
#!/bin/bash
#shell,echo linux
echo "helloworld!"
```
shell # **shell #! shell linuxbash shellshell zshdash...bash shell**
(4) :`./helloworld.sh` `./helloworld.sh` `helloworld.sh` `helloworld.sh` linux PATH helloworld.sh /bin, /sbin, /usr/bin/usr/sbin PATH PATH `helloworld.sh` `./helloworld.sh`

## Shell
### Shell
**Shell**
1. **:** Shell Shell
2. **Linux** $PATH, $HOME ..., `env` set
3. **Shell** Shell Shell Shell Shell
**:**
> PATH shell
HOME
HISTSIZE
LOGNAME
HOSTNAME
SHELL Shell
LANGUGE
MAIL
PS1root#$
** Linux **
`echo $HOME`Shell `echo $SHELL`
****
```shell
#!/bin/bash
#hello
hello="hello world"
echo $hello
echo "helloworld!"
```

**Shell **
- _
- _
-
- bashhelp
### Shell
shellJava
****
```shell
#!/bin/bash
name='SnailClimb'
hello='Hello, I am '$name'!'
echo $hello
```
```
Hello, I am SnailClimb!
```
****
```shell
#!/bin/bash
name='SnailClimb'
hello="Hello, I am "$name"!"
echo $hello
```
```
Hello, I am SnailClimb!
```
### Shell
****
```shell
#!/bin/bash
name="SnailClimb"
#
greeting="hello, "$name" !"
greeting_1="hello, ${name} !"
echo $greeting $greeting_1
#
greeting_2='hello, '$name' !'
greeting_3='hello, ${name} !'
echo $greeting_2 $greeting_3
```

****
```shell
#!/bin/bash
#
name="SnailClimb"
#
echo ${#name} # 10
#
expr length "$name";
```
:
```
10
10
```
expr :
```shell
expr 5+6 // 5+6
expr 5 + 6 // 11
```
`\`
```shell
expr 5 * 6 //
expr 5 \* 6 // 30
```
**:**
```shell
# 1 10
str="SnailClimb is a great man"
echo ${str:0:10} #:SnailClimb
```
```shell
#!bin/bash
#author:amau
var="http://www.runoob.com/linux/linux-shell-variable.html"
s1=${var%%t*}#h
s2=${var%t*}#http://www.runoob.com/linux/linux-shell-variable.h
s3=${var%%.*}#http://www
s4=${var#*/}#/www.runoob.com/linux/linux-shell-variable.html
s5=${var##*/}#linux-shell-variable.html
```
### Shell
bash Shell /
```shell
#!/bin/bash
array=(1 2 3 4 5);
#
length=${#array[@]}
#
length2=${#array[*]}
#
echo $length #5
echo $length2 #5
#
echo ${array[2]} #3
unset array[1]# 1
for i in ${array[@]};do echo $i ;done # 1 3 4 5
unset arr_number; #
for i in ${array[@]};do echo $i ;done #
```
## Shell
>
Shell
-
-
-
-
-
###

```shell
#!/bin/bash
a=3;b=3;
val=`expr $a + $b`
#Total value : 6
echo "Total value : $val"
```
###

shellscore=100AB
```shell
#!/bin/bash
score=90;
maxscore=100;
if [ $score -eq $maxscore ]
then
echo "A"
else
echo "B"
fi
```
```
B
```
###

```shell
#!/bin/bash
a=$(( 1 && 0))
# 0110
echo $a;
```
###

###

```shell
#!/bin/bash
a="abc";
b="efg";
if [ $a = $b ]
then
echo "a b"
else
echo "a b"
fi
```
```
a b
```
###

`file="/usr/learnshell/test.sh"` `if [ -r $file ]` `-w $file`
## shell
### if
if else-if else
```shell
#!/bin/bash
a=3;
b=9;
if [ $a -eq $b ]
then
echo "a b"
elif [ $a -gt $b ]
then
echo "a b"
else
echo "a b"
fi
```
```
a b
```
shell if Java PHP if shell if
### for
for for
****
```shell
for loop in 1 2 3 4 5
do
echo "The value is: $loop"
done
```
** 10 **
```shell
#!/bin/bash
for i in {0..9};
do
echo $RANDOM;
done
```
**15:**
shell $, for (()) ,
```shell
#!/bin/bash
for((i=1;i