【发布时间】:2017-10-14 19:22:32
【问题描述】:
我有一个问题。我想直接从文件中解压缩字符串。我在 bash 中有一个脚本可以创建另一个脚本。
#!/bin/bash
echo -n '#!/bin/bash
' > test.sh #generate header for interpreter
echo -n "echo '" >> test.sh #print echo to file
echo -n "My name is Daniel" | gzip -f >> test.sh #print encoded by gzip string into a file
echo -n "' | gunzip;" >> test.sh #print reverse commands for decode into a file
chmod a+x test.sh #make file executable
我想生成最短脚本的脚本 test.sh。我正在尝试压缩字符串“我的名字是丹尼尔”并将其直接写入文件 test.sh
但是如果我运行 test.sh 我得到 gzip: stdin has flags 0x81 -- not supported 你知道我为什么会遇到这个问题吗?
【问题讨论】:
标签: linux bash escaping gzip gunzip