0

I have a problem when I try to use this tar command :

cd /ROOT && tar -czf /ROOT/backup/test.tar.gz --exclude="backup" $(ls -A -1)

All the files and folder in the current directory are compressed without any problem, but some file contain some spaces in their name like "my file.log" and the tar return this error for them, and they are not compressed in the archive.

The error returned :

tar: my: Cannot stat: No such file or directory
tar: file.log: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

I want to use $(ls -A -1) because I want hidden files (begin with a dot), and if I use a . insted of $(ls -A -1) it's working but the . adds an uppermost level folder named . to the tar file. So this is the only solution that I have found for a clean archive.

So how I can use this command with filename which contain space ?

Thanks

0 Answers0