#!/bin/bash
#函数
fun()
{
#在函数中定义变量
#$#在函数里代表的函数的参数个数
str=hello
echo "fun \$#=$#"
echo "fun \$1=$1"
echo "fun \$2=$2"
echo "fun \$3=$3"
# local str=hello
# unset str
echo "fun run"
return 3
}
Mystr=hello
export Mystr
#环境变量
echo "my.sh pid=$$"
echo "my.sh Mystr=$Mystr"
#./a.sh $Mystr
./a.sh
source ./a.sh
#username=$1
#password=$2
#echo "username=$username"
#echo "password=$password"
#echo "my.sh run"
#echo "my.sh run"
#在函数外显示的是当前脚本的各项参数
# echo "fun \$#=$#"
# echo "fun \$1=$1"
# echo "fun \$2=$2"
# echo "fun \$3=$3"
#fun hello 123
#val=$?
#echo "val=$val"
#echo "str=$str"
# 变量 本地 环境 参数
#查找一个文件
#until [ -f a.txt ]
#do
# echo "not find a.txt"
# sleep 1
#done
#echo "find a.txt"
#i=1
#while [ "$i" -lt 5]
#do
# echo "i=$i"
# sleep 1
# let "i+=1"
#done
#echo "input"
#read line
#while( "$line" != "end")
#do
# printf "line=$line\n"
# read line
#done
#for循环
#for i in $(ls)
#do
# echo "i=$i"
# sleep 1
#done
#if
#echo "input:"
#read line
#if ( "$line" = "abc")
#then
# echo =
#对字符串是否相等做一个判断
#if
#echo "input:"
#read line
#if test "$line" = "123"
#then
# printf "==\n"
#else
# echo "!="
#fi
#echo "\$0=$0"
#echo "\$#=$#"
#echo "\$$=$$"
#echo "\$1=$1"
#echo "\$2=$2"
#val="100"
#mystr="$str"
#let "val+=1"
#val="expr $val + 1"
#echo "val=$val"
#read line
#echo "str=$str"
#echo "val=$val"
#echo "mystr=$mystr"
#echo "line=$line\n"
exit 0
cpp