学习写一个带参数执行的shell脚本,求大神指点

2024-12-16 14:06:53
推荐回答(2个)
回答1:

[root@localhost ~]# vim create.sh
#!/bin/bash
mysql -uroot -p123456 <create database $1;
EOF
[root@localhost ~]# sh create.sh b1

[root@localhost ~]# mysql -uroot -p123456 -e "show databases;"
+--------------------+
| Database |
+--------------------+
| information_schema |
| b1 |

回答2:

#!/bin/bash
mysql -uroot -p123456 <create database $1;
EOF