gpt4 book ai didi

linux - Zcat + awk 带绝对路径

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:51:23 26 4
gpt4 key购买 nike

在我的“test.tar.gz”中有一个文本文件:“test.txt”,其中:

col1 {tab} col2 {tab} col3

-

问题是,当我运行它时:

zcat ./folder1/test.tar.gz | awk -F '\t' '{print $1, $3}'

它返回:

test.txt

所以如果我添加:

zcat ./folder1/test.tar.gz | awk -F '\t' '{print $1, $3}' test.txt

它返回:

awk: cannot open test.txt (No such file or directory)

提前致谢!

最佳答案

尝试使用这样的东西:

tar -xzOf test.tar.gz test.txt | awk '{print $1, $3}'

这会从存档中提取文件 test.txt-O 开关将文件的内容发送到标准输出,然后可以将其通过管道传输到 awk。

关于linux - Zcat + awk 带绝对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30663209/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com