小编Ran*_*832的帖子

tar 及其关键字母:它是错误还是功能?

我想问一下这两个命令的区别(即只有它们的选项顺序不同):

  1. tar -zxvf foo.tar.gz
  2. tar -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 不需要这个限制,或者有吗?!因为在我看来开关应该是免费订购的。

linux command-line tar

18
推荐指数
3
解决办法
2924
查看次数

将一些带有标签的文本粘贴到 PuTTY 窗口中的此处文档中

我有一个带有制表符分隔数据的字符串,如下所示:

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 服务器。服务器是:

  • 发行版:Red Hat Enterprise Linux Server 6.6 版(圣地亚哥)
  • Bash 版本:4.1.2(1)-release (x86_64-redhat-linux-gnu)
  • 猫:coreutils-8.4-37.0.1.el6.x86_64

bash ssh putty clipboard here-document

5
推荐指数
1
解决办法
4897
查看次数

标签 统计

bash ×1

clipboard ×1

command-line ×1

here-document ×1

linux ×1

putty ×1

ssh ×1

tar ×1