试图用--files-from运行tar 。 我有一个文件files.txt包含
/dir1/files*.txt
然而它抱怨说/dir1/files*.txt不存在,但是certificate它确实存在。
我试图也添加--wildcards同样的结果。
如何在不使用命令行指定文件的情况下使用--files-from成功存档通配符?
命令中的星号在由shell(如bash)运行命令之前展开。
例如,当您运行ls *.txt ,并且在名为a.txt的目录中有三个txt文件时, b.txt和c.txt bash将其展开为ls a.txt b.txt c.txt
我不相信GNU tar支持这种行为,但是您可以使用find并将其find /dir1 -iname '*.txt' -printf '%P\n' | tar --files-from=- -cvf textfiles.tar到tar: find /dir1 -iname '*.txt' -printf '%P\n' | tar --files-from=- -cvf textfiles.tar find /dir1 -iname '*.txt' -printf '%P\n' | tar --files-from=- -cvf textfiles.tar
根据手册页 ,– --wildcards标志只能用于提取或列出已经存在的档案的内容。