shell脚本备忘
#!/usr/bin/bash echo "hello world" #for 循环和C一样 for ((i=1; i<11; i++)) do if ((i<10)); then #变量赋值,等号前后没有空格 tsk=test_0i else tsk=test_i fi #打印当前值 echo $tsk #判断目录是否存在 if [ -d $tsk ]; then rm -rf tskecho"tsk is exist, will delete and create new" mkdir $tsk else mkdir tskecho"tsk is not exist, it will be created" fi #shell copy当前文件到新目录 cp a b c d $tsk #shell进入新目录 cd tsk #shell sed替换xxx sed -i "s/xxx/tsk/g" d #shell返回上次目录 cd - done