在我的Oracle Linux中,我发现脚本块在/etc/profile
是很难搞清楚:
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
我的问题是在if语句${-#*i}
和$-
的变量。 这是什么意思?为什么要添加一个else语句来重定向输出? 谢谢!