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.
我有以下脚本:
#!/bin/bash function MySQLQuery() { echo $1 #mysql -u root -p << EOF #$1 #EOF } MySQLQuery "SELECT * FROM kunden;"
但输出是:SELECT install.sh FROM kunden。它将 * 替换为脚本的名称。我怎样才能防止这种情况?
或者有没有更好的解决方案?
问候,文斯
除了@Ansgar 建议的(MySQLQuery 'SELECT * FROM kunden;')之外,您还需要将$1参数括在引号中,例如:
MySQLQuery 'SELECT * FROM kunden;'
$1
echo "$1".
echo "$1"
这应该够了吧
您需要防止globbing。将字符串放在单引号中:
并双引号函数内的参数。