learn shell(updating....)

# First-Shell-Script

echo "hello world" # Anyway, you can writing another string , like `echo "fuck shell"`

In Linux , create new file test.sh , using vim to edit test.sh , coding first shell script. And use chmod +x test.sh give run permissions.

Then, run ./test.sh , like this:

# Shell-Variable

You can create variable in shell, example:

echo -e "str:${variable_str} \n int:${variable_int} \n float:${variable_float}"
# if you want to use escape character, like `\n`、`\t` and so on , you should use `echo -e` to print it, 
# if not, the string '\n' is printed instead of a newline character .

run ./test.sh , like this:

# String

string="fuck shell"
echo $string

# Intercept-String

You can use string slice to extract the substring , example:

string="fuck shell"
echo ${string:2:4}

Search by:GoogleBingBaidu