我想问一下这两个命令的区别(即只有它们的选项顺序不同):
tar -zxvf foo.tar.gztar -zfxv foo.tar.gz第一个运行完美,但第二个说:
tar: You must specify one of the `-Acdtrux' or `--test-label' options
Try `tar --help' or `tar --usage' for more information.
Run Code Online (Sandbox Code Playgroud)
而焦油--test-label和-zfxv说:
tar (child): xv: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Run Code Online (Sandbox Code Playgroud)
然后我查看了 tar 手册,发现里面的所有示例最终都使用了 switch -f!!
AFAICT 不需要这个限制,或者有吗?!因为在我看来开关应该是免费订购的。
我有一个带有制表符分隔数据的字符串,如下所示:
h1 h2
a1 b1
a2 b2
Run Code Online (Sandbox Code Playgroud)
我在 Windows 上用记事本制作了它。我创建了制表符分隔的数据,确保使用制表符而不是空格。

我使用 PuTTY 通过 SSH 连接到 Linux 服务器。我想将文件写入/tmp/test.txt并保留选项卡。所以我跑cat <<EOF >/tmp/test.txt。我从记事本复制文本并将其粘贴到腻子会话中。然后我输入EOF。

但是,这会生成一个没有选项卡的文件,其中包含以下内容:
h1h2
a1b1
a2b2
Run Code Online (Sandbox Code Playgroud)
我发现这有效:
sed 's/\\t/\t/g' > /tmp/test.txt << EOF
h1\th2
a1\tb1
a2\tb2
EOF
Run Code Online (Sandbox Code Playgroud)
但是,它要求我将输入字符串更改为使用 '\t' 而不是实际的制表符。什么是更优雅/简单的解决方案,它允许我从 Windows 按原样获取字符串文字并将其写入远程 Linux 机器上的文件?
我通过 putty 从 Windows SSH 连接到 Linux 服务器。服务器是: