0
這是我想要做的。我想grep(也許?)一個文件的關鍵字根據我發現做的等等。Bash if grep或grep elif grep?所以很困惑
if grep "env=" does not exist OR "env=" exists but is null file.name; then
env=prod
elif grep "env=dev" OR "env=qa" file.name; then
env=dev/qa respectivly
我嘗試一些grep命令,但被卡住與
不知道這是否得到它,但仍然需要測試
if ! grep -q -E "^environment=" "${__file}" | grep -q -e "dev|qa|prod"; then
if [ -n "${ENV}" ]; then
echo "environment=${ENV}" >> "${__file}"
else
echo "environment=prod" >> "${__file}"
fi
fi