I'm trying to use tar(1) to create an archive of files newer than a specific file (fileA
). However, when I use find(1) to obtain the list of files to pass to tar, some files are listed multiple times:
$ touch fileA
$ mkdir test
$ touch test/{fileB,fileC}
$ tar -c -v $(find test -newer fileA) > test.tar
test/
test/fileC
test/fileB
test/fileC
test/fileB
Using xargs(1) to pass the list of files to tar results in similar behavior:
$ find test -newer fileA | xargs tar -c -v > test.tar
test/
test/fileC
test/fileB
test/fileC
test/fileB
Using sort(1) and uniq(1) to remove duplicates doesn't work either:
$ find test -newer fileA | sort | uniq | xargs tar -c -v > test.tar
test/
test/fileC
test/fileB
test/fileB
test/fileC
Is there a way for tar to only include each file newer than fileA
once?
Edit: I'm specifically looking for a solution that doesn't involve GNU extensions to tar (for example, which would work with suckless tar).