On Wed, Sep 21, 2022 at 12:31:58PM +0100, jr wrote: > > > $ tar -cvWf $arcname $fnames > > > > > > where $fnames initially was a list in a variable (this is preparing a > > > shell script), then I switched to storing in those in a file and > > > $ tar -cvWf $arcname $(cat $fname_list_file) > > So... what's in these variables? What's in the file pointed to by > > the last variable? > > "what's in these variables?" > > $arcname := name of archive, eg '/tmp/220921_bkup.tar'. > $fname_list_file := the name of a file much like the previous. > > "What's in the file" > > file names, one per line. (and, before you ask, '\n' terminated lines)
This is not helpful. We want to see the ACTUAL CONTENTS so we can look for DUPLICATES. How are you not understanding this? > "your approach ... is utterly crap" > > charming. </shrug> (and yet, in spite of your .. low opinion, I do get by > ;-)) Do you need a DEMONSTRATION of how it is broken and wrong? unicorn:/tmp/x$ mkdir -p sub1/sub2 unicorn:/tmp/x$ touch sub1/sub2/{file1,file2,'* file3 *'} unicorn:/tmp/x$ not_safe=$(find . -type f) unicorn:/tmp/x$ tar cf ../foo.tar $not_safe tar: file3: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors unicorn:/tmp/x$ tar tvf ../foo.tar -rw-r--r-- greg/greg 0 2022-09-21 07:54 ./sub1/sub2/file2 -rw-r--r-- greg/greg 0 2022-09-21 07:54 ./sub1/sub2/file1 hrw-r--r-- greg/greg 0 2022-09-21 07:54 ./sub1/sub2/file1 link to ./sub1/sub2/file1 hrw-r--r-- greg/greg 0 2022-09-21 07:54 ./sub1/sub2/file2 link to ./sub1/sub2/file2 -rw-r--r-- greg/greg 0 2022-09-21 07:54 ./sub1/sub2/* file3 * drwxr-xr-x greg/greg 0 2022-09-21 07:54 sub1/ drwxr-xr-x greg/greg 0 2022-09-21 07:54 sub1/sub2/ hrw-r--r-- greg/greg 0 2022-09-21 07:54 sub1/sub2/file2 link to ./sub1/sub2/file2 hrw-r--r-- greg/greg 0 2022-09-21 07:54 sub1/sub2/file1 link to ./sub1/sub2/file1 hrw-r--r-- greg/greg 0 2022-09-21 07:54 sub1/sub2/* file3 * link to ./sub1/sub2/* file3 * See how this is YET ANOTHER way we can reproduce your original symptoms? You "get by" because you've been getting LUCKY so far. Bash has array variables. You can use array variables to hold lists, safely, including all possible filenames. GNU tar has --files-from which you can use to point to a file that contains a list of filenames one per line. You can use that instead of your incredibly broken $(cat $unquoted_filename) nonsense. But clearly you're not terribly invested in finding the answers to your problems, and I'm running out of patience with you, so... good luck.