使用tar将文件从几个源目录收集到一个普通存档

时间:2022-08-02 22:09:23

I'm searching for hours now to get tar skipping all directory structure.

我现在正在搜索几小时来获取tar跳过所有目录结构。

The closest approach to get what I want is the following:

获得我想要的最接近的方法如下:

tar cf foo.tar -C /data/2012/12/12/00 . -C /data/2012/12/12/01 . -C /data/2012/12/12/03 .

tar cf foo.tar -C / data / 2012/12/12/00。 -C / data / 2012/12/12/01。 -C / data / 2012/12/12/03。

The Problem: All files in the archive are located in the "." -folder. But they are expected in the root of archive.

问题:存档中的所有文件都位于“。”中。 -夹。但他们应该在档案的根源。

Anyone out there with a hint for me?

那里有人暗示我的人吗?

1 个解决方案

#1


1  

I think you want the --transform option:

我想你想要--transform选项:

--transform 's,^\./,,'

I tried this on BSD with its similar -s option and it worked for me.

我在BSD上用类似的-s选项尝试了这个,它对我有用。

#1


1  

I think you want the --transform option:

我想你想要--transform选项:

--transform 's,^\./,,'

I tried this on BSD with its similar -s option and it worked for me.

我在BSD上用类似的-s选项尝试了这个,它对我有用。