[beyes@localhost shell]$ sh -n menu.sh
menu.sh: line 8: unexpected EOF while looking for matching `''
menu.sh: line 10: syntax error: unexpected end of file
#!/bin/bash
echo "hello"
echo "world"
date
ls -al
[beyes@localhost shell]$ sh -x menu.sh
+ echo hello
hello
+ echo world
world
+ date
Sun May 29 18:53:43 PDT 2011
+ ls -al
total 12
drwxrwxr-x. 2 beyes beyes 4096 May 29 18:53 .
drwx------. 25 beyes beyes 4096 May 29 18:53 ..
-rw-rw-r--. 1 beyes beyes 249 May 29 18:53 menu.sh
#!/bin/bash
echo "hello"
echo "world"
ifdown eth0 #普通用户没有权限配置网卡
date
[beyes@localhost shell]$ sh menu.sh
hello
world
Users cannot control this device.
Sun May 29 19:01:18 PDT 2011
[beyes@localhost shell]$ sh -e menu.sh
hello
world
Users cannot control this device.
[beyes@localhost shell]$ ls *.sh
ls: cannot access *.sh: No such file or directory
[beyes@localhost shell]$ set +f
[beyes@localhost shell]$ ls *.sh
menu.sh
[beyes@localhost shell]$ set -C
[beyes@localhost shell]$ touch file1
[beyes@localhost shell]$ echo "hello world" > file1
bash: file1: cannot overwrite existing file
[beyes@localhost shell]$ set +C
[beyes@localhost shell]$ echo "hello world" > file1
选项名 | 快捷键开关 | 含义 |
allexport | -a | 从这个选项被设置开始就自动标明要输出的新变量或修改过的变量,直至选项被复位 |
braceexpand | -B | 打开花括号扩展,是一个缺省设置 |
emacs | 使用emacs内置编辑器进行命令行编辑,是一个缺省设置 | |
errexit | -e | 当命令返回一个非0退出状态(失败)时退出,读取初始化文件时不设置 |
histexpand | -H | 执行历史替换时打开!和!!扩展,是一个缺省设置 |
history | 打开命令行历史;缺省为打开 | |
ignoreeof | 禁止用EOF(Control-D)键退出shell;必须输入exit才能退出。和设置shell变量IGNOREEOF=10一样 | |
keyword | -k | 将关键字参数放到命令的环境中 |
interactive-comments | 对于交互式shell,#用来将后面的文件作为注释 | |
monitor | -m | 设置作业控制 |
noclobber | -C | 防止文件在重定向时被重写 |
noexec | -n | 读命令,但不执行。用来检查脚本的语法。交互式运行时不设置 |
noglob | -d | 禁止用户路径名扩展;即关闭通配符 |
notify | -b | 通知用户什么时候后台作业完成 |
nounset | -u | 扩展一个没有设置的变量时显示一个错误信息 |
onecmd | -t | 在读取和执行命令后退出 |
physical | -P | 设置时,在键入cd或pwd时禁止符号连接。用物理目录代替 |
posix | 如缺省操作不符合POSIX标准就改变shell行为 | |
privileged | -p | 设置时,shell不读,profile或ENV文件,且不从环境继承shell函数;自动为setuid脚本开启特权 |
verbose | -v | 为调试打开verbose模式 |
vi | 使用vi内置编辑器进行命令行编辑 | |
xtrace | -x | 为调试打开跟踪模式 |
[beyes@localhost ~]$ set -o ignoreeof
#按下 ctrl + d
[beyes@localhost ~]$ Use "exit" to leave the shell.
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |