【发布时间】:2018-04-28 20:36:15
【问题描述】:
我正在尝试使用cat data.txt | redis-cli --pipe 中提到的命令https://redis.io/topics/mass-insert 执行Redis 批量插入。
必须转换 macOS 上的数据格式,以便可以使用 cat ${FILE} | perl -i -p -e 's|[\r\n]+|\r\n|g' | redis-cli --pipe 执行批量插入。
但是,上述命令不适用于 Linux 环境(或具有基于 alpine 的映像构建的容器的 docker 环境)。相反,必须执行以下命令cat ${FILE} | sed 's/\r*$/\r/' | redis-cli --pipe。
有在这两种环境下都可以使用的命令吗?
编辑:附上以下内容:
Alpine Linux 上的 Redis 批量插入脚本:https://gist.github.com/francjohny/f2b13b4cfc147e07e52824ec88ba3781
Mac OS 上的 Redis 批量插入脚本:https://gist.github.com/francjohny/b57756a1e0124dd562959ca5ece2a32b
Redis 协议格式数据文件:https://gist.github.com/francjohny/0c21f32d9902809b215f4e92f5e6a9f1
➜ head ouput.rpf| xxd - Mac OS: https://gist.github.com/francjohny/e1a646ab44e7edd7374d28e9ca400711➜ head ouput.rpf| xxd - Alpine Linux:https://gist.github.com/francjohny/252904928ded4c045448d12b205228df
【问题讨论】:
-
请点击您的问题下方的
edit并添加两个系统上生成的head -e data.txt | xxd的输出,这样我们就可以看到您当前的行尾是什么样的。 -
@MarkSetchell 抱歉,您的意思是
head data.txt | xxd吗? -
@MarkSetchell 我已附上请求的文件。请看一看。