![](/img/trans.png)
[英]Export blob column from mysql dB to disk and replace it with new file name
[英]Export blob from mysql to file in bash script
我正在尝试编写一个bash脚本,除其他外,该脚本从mysql数据库中提取信息。 我尝试了以下操作以从条目20中提取文件:
mysql -se "select file_column_name from table where id=20;" >file.txt
那给了我一个file.txt文件,而不是文件内容。 我如何将实际的blob放入file.txt?
将file.txt
的值转换为变量,然后根据需要使用它? 即
blobFile=$(cat file.txt)
echo "----- contents of $blobFile ---------"
cat $blobFile
# copy the file somewhere else
scp $blobFile user@Remote /path/to/remote/loc/for/blobFile
# look for info in blobfile
grep specialInfo $blobFile
# etc ...
那是您想要/需要做的吗?
我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.