eval命令的作用
时间:2008-03-03 来源:ller
eval
eval args
Typically, eval is used in shell scripts, and args is a line of code that contains
shell variables. eval forces variable expansion to happen first and then runs
the resulting command. This “double-scanning” is useful any time shell vari-
ables contain input/output redirection symbols, aliases, or other shell vari-
ables. (For example, redirection normally happens before variable expansion,
so a variable containing redirection symbols must be expanded first using
eval; otherwise, the redirection symbols remain uninterpreted.)
Example
This fragment of a shell script shows how eval constructs a command that is
interpreted in the right order:
for option
do
case "$option" inDefine where output goes
save) out=’ > $newfile’ ;;
show) out=’ | more’ ;;
esac
done
eval sort $file $out
<<Bash Quick Reference>>
eval args
Typically, eval is used in shell scripts, and args is a line of code that contains
shell variables. eval forces variable expansion to happen first and then runs
the resulting command. This “double-scanning” is useful any time shell vari-
ables contain input/output redirection symbols, aliases, or other shell vari-
ables. (For example, redirection normally happens before variable expansion,
so a variable containing redirection symbols must be expanded first using
eval; otherwise, the redirection symbols remain uninterpreted.)
Example
This fragment of a shell script shows how eval constructs a command that is
interpreted in the right order:
for option
do
case "$option" inDefine where output goes
save) out=’ > $newfile’ ;;
show) out=’ | more’ ;;
esac
done
eval sort $file $out
<<Bash Quick Reference>>
相关阅读 更多 +
- 系统休眠文件删除后果 如何删除计算机的休眠文件 2025-04-22
- 站群服务器是什么意思 站群服务器的作用 站群服务器和普通服务器的区别 2025-04-22
- jQuery插件有何作用 jQuery插件的使用方法 2025-04-22
- jQuery插件有哪些种类 简单的jQuery插件实例 2025-04-22
-