LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-24-2006, 01:06 PM   #1
soaked
LQ Newbie
 
Registered: Jul 2005
Distribution: RHEL v3
Posts: 17

Rep: Reputation: 0
Using tar on filenames containing spaces


I had an incremental backup script that produces a tarball of all files that have been amended in the last 7 days. It includes this line:

Code:
tar -rf /var/www/vhosts/<***>/tarbackupw_`date +%Y_%m_%d`.tar `find /var/www/vhosts/<***>/forums -type f -mtime -7`
It used to work fine, but now I have a new 3rd party script which produces files on the server that contain spaces in the filenames. So now I get this kind of error:

Code:
tar: /var/www/vhosts/<***>/forums/downloads/files/36-rct: Cannot stat: No such file or directory
tar: grand: Cannot stat: No such file or directory
tar: glacier.zip: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
(The filename is "36-rct grand glacier.zip")

Please can anybody suggest a similar script that will produce a tarball WITHOUT changing the filenames?
 
Old 07-24-2006, 01:21 PM   #2
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
Try that:
Quote:
tar -rf /var/www/vhosts/<***>/tarbackupw_`date +%Y_%m_%d`.tar `find /var/www/vhosts/<***>/forums -type f -mtime -7 -exec echo \"{}\" \;`
to get "36-rct grand glacier.zip" with the double quotes for each file.

Last edited by berbae; 07-24-2006 at 01:28 PM.
 
Old 07-24-2006, 01:21 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 122Reputation: 122
Yes, try:
Code:
tar -rf /var/www/vhosts/<***>/tarbackupw_`date +%Y_%m_%d`.tar `find /var/www/vhosts/<***>/forums -type f -mtime -7 -exec echo "{}" \;`
 
Old 07-24-2006, 01:35 PM   #4
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
Hi Matir
Same idea at the same time!
But the double quotes in the echo must be backslashed.
 
Old 07-24-2006, 01:37 PM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 122Reputation: 122
Oops, yeah, they should be. Sorry, didn't test it before I posted it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
spaces in filenames dotancohen Programming 12 02-17-2006 03:42 PM
Convert filenames with spaces? Macky Linux - General 1 12-05-2005 06:48 PM
filenames with spaces antony.booth Programming 5 11-01-2005 05:49 AM
ls and filenames with spaces rose_bud4201 Programming 10 07-01-2005 09:28 AM
spaces in filenames ebone Linux - General 2 11-12-2001 12:56 PM


All times are GMT -5. The time now is 01:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration