【发布时间】:2014-07-16 14:01:39
【问题描述】:
我想制作一个非交互式的 shell 脚本,我可以在脚本执行开始时提供选项。
当用户提供不同的输入时,我可以硬编码要采取的各种操作。
例如:
下面应该对target.txt执行一些操作
user@/root>myPlannedScript -p targer.txt
下面应该对target.txt执行一些其他操作
user@/root>myPlannedScript -a targer.txt
例如:
cat 工具在给出不同选项时执行各种操作。我希望我的脚本是这样的:
:/root> cat --h
Usage: cat [OPTION] [FILE]...
Concatenate FILE(s), or standard input, to standard output.
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonblank output lines
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-r, --reversible use \ to make the output reversible, implies -v
-s, --squeeze-blank never more than one single blank line
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
【问题讨论】:
-
你到底有什么问题?
-
我有一个脚本,我使用用户交互(读取工具)来提供 target.txt,现在我想通过在一行中提供 target.txt 文件名来一次性执行此命令.
标签: linux bash shell scripting