如果我需要它,我可能会这样构建字符串:
x='a seemingly infinitely long '
x="$x"'string requiring continuatio'
x="$x"'n on the next line...'
a_long_variable_name="$x"
或该主题的细微变化。或者我会在每一行重复长变量名。这是我使用的真实脚本——它为我列出了相关的环境变量:
informix1="DB[^=]|DELIMIDENT=|SQL|ONCONFIG|TBCONFIG|INFOR"
informix2="CLIENT_LOCALE=|GL_|GLS8BITSYS|CC8BITLEVEL|ESQL|FET_BUF_SIZE="
informix3="INF_ROLE_SEP=|NODEFDAC=|ONCONFIG|OPTCOMPIND|PDQ|PSORT"
informix4="PLCONFIG|SERVER_LOCALE|FGL|C4GL|NE_"
informix5="TCL_LIBRARY|TK_LIBRARY|TERM=|TERMCAP=|TERMINFO="
informix="$informix1|$informix2|$informix3|$informix4|$informix5"
system1="COLLCHAR=|LANG=|LC_"
system2="(DY)?LD_LIBRARY_PATH(_[63][42])?=|PATH=|SHLIB_PATH=|LIBPATH="
system="$system1|$system2"
jlss="IX([A-Z]|D(32|64)?)="
env |
${EGREP:-egrep} "^($informix|$system|$jlss)" |
sort
(当 Mac OS X 10.7.x因为它“太大”而停止处理表达式时,切换使用哪个egrep
程序的能力变得必要。)egrep