diff --git "a/shell\345\255\246\344\271\2401-\345\270\270\347\224\250\345\221\275\344\273\244/.swp" "b/shell\345\255\246\344\271\2401-\345\270\270\347\224\250\345\221\275\344\273\244/.swp" new file mode 100644 index 0000000..6bc52c7 Binary files /dev/null and "b/shell\345\255\246\344\271\2401-\345\270\270\347\224\250\345\221\275\344\273\244/.swp" differ diff --git "a/shell\345\255\246\344\271\2401-\345\270\270\347\224\250\345\221\275\344\273\244/demo1.sh" "b/shell\345\255\246\344\271\2401-\345\270\270\347\224\250\345\221\275\344\273\244/demo1.sh" index b94cf93..c436972 100755 --- "a/shell\345\255\246\344\271\2401-\345\270\270\347\224\250\345\221\275\344\273\244/demo1.sh" +++ "b/shell\345\255\246\344\271\2401-\345\270\270\347\224\250\345\221\275\344\273\244/demo1.sh" @@ -1,3 +1,29 @@ #!/bin/bash -echo "hello word !" \ No newline at end of file +echo " +运行Shell脚本有两种方法: +1、作为可执行程序 +先cd到相应目录: +chmod +x ./test.sh #使脚本具有执行权限 +./test.sh #执行脚本 +注意,一定要写成./test.sh,而不是test.sh,运行其它二进制的程序也一样,直接写test.sh,linux系统会去PATH里寻找有没有叫test.sh的,而只有/bin, /sbin, /usr/bin,/usr/sbin等在PATH里,你的当前目录通常不在PATH里,所以写成test.sh是会找不到命令的,要用./test.sh告诉系统说,就在当前目录找。 +2、作为解释器参数 +这种运行方式是,直接运行解释器,其参数就是shell脚本的文件名,如: +/bin/sh test.sh +/bin/php test.php +这种方式运行的脚本,不需要在第一行指定解释器信息,写了也没用。 +" + + +:<