【发布时间】:2013-09-29 19:09:29
【问题描述】:
我正在尝试从 mysql 数据库中获取多条记录,并将它们输出到我拥有的文本文件的单行中
#!/bin/bash
result_storage="/tmp/book"
id=$(mysql --host=host --user=user --password=password --database=db -s -N -e "selectcount(*) from people")
echo -e "$id New" > $result_storage
id2=$(mysql --host=host --user=user --password=password --database=db -s -N -e "select count(*) from numbers")
sed '1 s|$|"$id2" Numbers|' -i $result_storage
但是 sed 部分打印 $id2 而不是来自 id2 的计数
基本上最后我想 /tmp/book 阅读
12 个人 10 个号码
【问题讨论】: