【发布时间】:2013-10-21 00:42:26
【问题描述】:
我像
一样运行我的脚本./test.sh -c "red blue yellow"
./test.sh -c "red blue"
而在 bash 中,变量“color”将被赋值为“red blue yellow”或“red blue”
echo $collor
red blue yellow
两个问题:
A:“红色”对我来说是一个重要的参数,我怎么知道红色是否包含在可变颜色中?
if [ red is in color] ; then "my operation"
B:我有一个只有 3 种颜色的颜色列表,如何检查是否有未定义的颜色传递给脚本
./test.sh -c "red green yellow"
如何定义颜色列表以及如何进行检查以便获得打印件
Warnings: wrong color is green is passed to script
谢谢
【问题讨论】: