我想用约。 Bash中的以下构造用于在PostgreSQL的配置文件中生成行:
T0=$(date +%s)
cat > $PGDATA/recovery.conf <<EOL
recovery_target_inclusive = true
recovery_target_time = \'$(date -d @$T0 "+%Y-%m-%d %H:%M:%S %Z")\'
recovery_target_timeline = latest
EOL
我目前收到此输出:
recovery_target_inclusive = true
recovery_target_time = \'2018-01-04 12:47:44 UTC\'
recovery_target_timeline = latest
如何获得不会丢失单引号的版本?
答案 0 :(得分:1)
简单:不要逃避引号。
cat > $PGDATA/recovery.conf <<EOL
recovery_target_inclusive = true
recovery_target_time = '$(date -d @$T0 "+%Y-%m-%d %H:%M:%S %Z")'
recovery_target_timeline = latest
EOL