正在加载图片...
●用户在登录 Shell时,会依次执行一系列的脚本 ●使用 alias命令,可以定义一些别名。 ' -f 登录BASH时,用户将依次执行一系列的脚本:/etc/ profile, SHOME/. bash profile (如果没有,执行$HOME/.bash_ login,还没有,执行$HOME/. profile)。注销时,会自 动执行 SHOME/. bash logout 使用 redhat的用户,登录时除了这两个文件以外,还会自动执行$HOME/. bashrc, 这个文件又会再执行/etc/ bashrc 1.6条件控制 1)test命令 测试文件、变量的属性,表达式的值,或命令执行返回值。 test-d /usr >[d /usr test -f. bashrc >[-f bashrc test Scount -gt 0>[Scount -gt0] 2)if语句 if(expression) then command-list command-list fi 3)case语句 pattern2)command-list 4)逻辑运算符&&和‖ test-f myfile c & echo"file found if test-f myfile c ther echo“ file found” test-f myfilec l echo "file not found if test!-f myfile c the echo“ file not foun 1.7循环控制● 用户在登录 Shell 时,会依次执行一系列的脚本。 ● 使用 alias 命令,可以定义一些别名。 Alias ‘rm –f’ rm 登录 BASH 时,用户将依次执行一系列的脚本:/etc/profile , $HOME/.bash_profile ( 如果没有,执行 $HOME/.bash_login ,还没有,执行 $HOME/.profile)。注销时,会自 动执行 $HOME/.bash_logout 。 使用 redhat 的用户,登录时除了这两个文件以外,还会自动执行 $HOME/.bashrc , 这个文件又会再执行 /etc/bashrc 1.6 条件控制 1)test 命令 测试文件、变量的属性,表达式的值,或命令执行返回值。 test –d /usr → [ -d /usr ] test –f .bashrc → [ -f .bashrc ] test $count –gt 0 → [ $count –gt 0 ] 2)if 语句 if (expression) then command-list else command-list fi 3)case 语句 case $var in pattern1) command-list ;; pattern2) command-list ;; … esac 4)逻辑运算符 && 和 || # test –f myfile.c && echo “file found” if test –f myfile.c then echo “file found” fi # test –f myfile.c | | echo “file not found” if test ! –f myfile.c then echo “file not found” fi 1.7 循环控制
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有