LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 11-01-2011, 12:30 PM   #1
venom4u31
Member
 
Registered: Oct 2011
Distribution: Debian 6
Posts: 47

Rep: Reputation: Disabled
Tar won't escape characters


I am trying to make an archive using tar. The paths to the files I want to put into the archive are located on a file (named fis). However, some paths have folders with spaces in them and I cannot modify that.
When I try to create the archive using:
Code:
tar -cvjf archive.tar.bz2 `cat fis`
it tells me that some files cannot be found like this:
Code:
tar: ./United: Cannot stat: No such file or directory
tar: Kingdom/noz: Cannot stat: No such file or directory
where the file to be archived is ./United Kingdom/noz

When I change the text from fis to ./United\ Kingdom thus escaping the space, the program outputs (at the same instruction:
Code:
tar: ./United\\: Cannot stat: No such file or directory
tar: Kingdom/noz: Cannot stat: No such file or directory
I noticed that it uses another \ to escape its ":", so it is familiar with escaping. I tried quoting in single and double quotes the folder name and it still does not work.

The rest of the folders (without spaces in them) are archived perfectly well. Also, inserting the address from the keyboard works as well.

Can you please tell me how to create that archive using the list of addresses from fis? Adding (or appending) them manually is clearly not an option. If you can suggest another method of redirecting please quote the corresponding command. You have the names there. And the working directory contains the file "fis" that contains the addresses.
 
Old 11-01-2011, 01:49 PM   #2
trbennett48
LQ Newbie
 
Registered: Apr 2011
Location: Oregon
Posts: 25

Rep: Reputation: 3
How about this:
Code:
tar --files-from=fis -cvjf archive.tar.bz2
 
Old 11-01-2011, 02:07 PM   #3
venom4u31
Member
 
Registered: Oct 2011
Distribution: Debian 6
Posts: 47

Original Poster
Rep: Reputation: Disabled
It worked like a charm! Thanks a lot. I would ask you about classic redirecting that won't work with echo... for example
Code:
echo < fis
displays a blank line. I'll probably start a new thread.
 
  


Reply



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
escape characters in Linux apeselis Programming 1 11-11-2010 04:16 PM
List of '\e' escape characters, please Kenny_Strawn Programming 3 07-21-2010 01:02 PM
[SOLVED] Having trouble with escape characters in C madsovenielsen Programming 5 03-03-2010 06:36 AM
Variables and escape characters? flobadon Programming 4 09-10-2005 04:34 PM
Escape Characters in linux shunraj Linux - Software 1 05-18-2004 03:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:39 AM.

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
Open Source Consulting | Domain Registration