我想阻止# if CLOUDSDK_PYTHON is empty
if [ -z "$CLOUDSDK_PYTHON" ]; then
# if python2 exists then plain python may point to a version != 2
if _cloudsdk_which python2 >/dev/null; then
CLOUDSDK_PYTHON=python2
elif _cloudsdk_which python2.7 >/dev/null; then
# this is what some OS X versions call their built-in Python
CLOUDSDK_PYTHON=python2.7
elif _cloudsdk_which python >/dev/null; then
# Use unversioned python if it exists.
CLOUDSDK_PYTHON=python
elif _cloudsdk_which python3 >/dev/null; then
# We support python3, but only want to default to it if nothing else is
# found.
CLOUDSDK_PYTHON=python3
else
# This won't work because it wasn't found above, but at this point this
# is our best guess for the error message.
CLOUDSDK_PYTHON=python
fi
fi
使用sed
编辑命令添加换行符:
i
我想要的结果是:
> `echo "hello" | sed 'i TEST'`
TEST
hello
答案 0 :(得分:0)
我认为这是不可能的。改为这样:
sed 's/^/TEST/' file
答案 1 :(得分:0)
您也可以尝试以下方法:
echo "hello" | sed "s/$/TEST/"
这是在用所需的文本替换行尾(/$/)。