小编Dav*_*her的帖子

如何在 bash 管道中处理原始二进制数据?

我有一个 bash 函数,它将文件作为参数,验证文件是否存在,然后将来自 stdin 的任何内容写入文件。天真的解决方案适用于文本,但我遇到了任意二进制数据的问题。

echo -n '' >| "$file" #Truncate the file
while read lines
do  # Is there a better way to do this? I would like one...
    echo $lines >> "$file"
done
Run Code Online (Sandbox Code Playgroud)

shell bash binary

16
推荐指数
2
解决办法
3万
查看次数

标签 统计

bash ×1

binary ×1

shell ×1