Alright, so simple problem here. I'm working on a simple back up code. It works fine except if the files have spaces in them. This is how I'm finding files and adding them to a tar archive:
find . -type f | xargs tar -czvf backup.tar.gz
The problem is when the file has a space in the name because tar thinks that it's a folder. Basically is there a way I can add quotes around the results from find? Or a different way to fix this?
Try running:
Why not give something like this a try:
tar cvf scala.tar `find src -name *.scala`
If you have multiple files or directories and you want to zip them into independent
*.gz
file you can do this. Optional-type f -atime
This will compress
to
The best solution seem to be to create a file list and then archive files because you can use other sources and do something else with the list.
For example this allows using the list to calculate size of the files being archived:
Why not:
Sure it's clever to use find and then xargs, but you're doing it the hard way.
Update: Porges has commented with a find-option that I think is a better answer than my answer, or the other one:
find -print0 ... | xargs -0 ....
Another solution as seen here: