开发者

Export blob from mysql to file in bash script

I'm trying to write a bash scrip开发者_JAVA百科t that, among other things, extracts information from a mysql database. I tried the following to extract a file from entry 20:

mysql -se "select file_column_name from table where id=20;" >file.txt

That gave me a file.txt with the file name, not the file contents. How would I get the actual blob into file.txt?


Turn the value in file.txt into a variable and then use it as you need to? i.e.

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 ...

Is that what you want/need to do?

I hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜