Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
CMD="mysqldump -usomeuser -psomepass db_name \> /../SQL_$(date +'%m-%d-%Y').sql"
以上抛出以下异常:
mysqldump:找不到表:“>”
"&1>" 也被视为表名。
我尝试了 -all-database(s) 选项,但这也不起作用。
谢谢!
您不能在命令中转义大于:
CMD="mysqldump -usomeuser -psomepass db_name > /../SQL_$(date +'%m-%d-%Y').sql"
即使这样,如果您尝试仅通过调用它来执行命令,bash 会将大于号视为位置参数。您可以通过调用 sh 或 bash 来执行它:
bash -c "$CMD"