Using tar with filenames that have blank spaces

Using tar with filenames that have blank spaces

Post by James » Thu, 19 Jun 2003 13:06:26



I need to create a tar file for each application by reading its files
from an inputlist with 100 to 500 items.  Under the Mac OS X system
gnutar (1.13) has this option but tar doesn't. The filenames have
blank spaces between them and look like this:

/Library/Application Support/Application
name/Color/Profiles/CIERGB.icc
(there are other sub-directories and files under "/Library/Application
Support/Application name/"

/Users/admin/Library/Preferences/com.apple.nsl.ui
(there are other sub-directories and files under
"/Users/admin/Library/"

and so on.

If I try reading the filename from the input list as:
/Library/Application Support/Application
name/Color/Profiles/CIERGB.icc
I get the error message that "No such file or directory"

If I try reading as:
"/Applications/Application name/Examples/Curve Fits/Enzyme
Kinetics/mmf.TXT"
I get the message 'Cannot add file ": No such file or directory'

and for "Applications/Application name/Examples/Curve Fits/Enzyme
Kinetics/mmf.TXT"
I get the message 'Cannot add file ": No such file or directory'

Any tips on how to address this problem? Thanks!

James

 
 
 

Using tar with filenames that have blank spaces

Post by Frank Cusac » Thu, 19 Jun 2003 14:32:37



Quote:> I need to create a tar file for each application by reading its files
> from an inputlist with 100 to 500 items.  Under the Mac OS X system
> gnutar (1.13) has this option but tar doesn't. The filenames have
> blank spaces between them and look like this:

> /Library/Application Support/Application
> name/Color/Profiles/CIERGB.icc
> (there are other sub-directories and files under "/Library/Application
> Support/Application name/"

> /Users/admin/Library/Preferences/com.apple.nsl.ui
> (there are other sub-directories and files under
> "/Users/admin/Library/"

> and so on.

> If I try reading the filename from the input list as:
> /Library/Application Support/Application
> name/Color/Profiles/CIERGB.icc
> I get the error message that "No such file or directory"

What do you mean "if I try reading ..."?  How are you doing this reading?
tar -T should do this correctly.

/fc

 
 
 

Using tar with filenames that have blank spaces

Post by John » Thu, 19 Jun 2003 22:21:08


Try changing

..../Curve Fits/
to
..../Curve\Fits/

You need to delimit the space.

John M

 
 
 

Using tar with filenames that have blank spaces

Post by Stein Arne Storslet » Thu, 19 Jun 2003 22:52:47



Quote:> I need to create a tar file for each application by reading its files
> from an inputlist with 100 to 500 items.  Under the Mac OS X system
> gnutar (1.13) has this option but tar doesn't. The filenames have
> blank spaces between them and look like this:

> /Library/Application Support/Application
> name/Color/Profiles/CIERGB.icc
> (there are other sub-directories and files under "/Library/Application
> Support/Application name/"

> /Users/admin/Library/Preferences/com.apple.nsl.ui
> (there are other sub-directories and files under
> "/Users/admin/Library/"

while read i
do
  [ -f tarfile.tar ] &&
                     tar uf tarfile.tar "$i" ||
                     tar cf tarfile.tar "$i"
done < filelist.txt

--
Stein Arne

 
 
 

Using tar with filenames that have blank spaces

Post by Doug Freyburg » Thu, 19 Jun 2003 23:52:16



> The filenames have blank spaces between them and look like this:
> ...
> Any tips on how to address this problem? Thanks!

Use tar t > some.file

1) Edit some.file and bracket the files with spaces in double quotes.

2) Use something like xargs < some.files tar x to get each of the
files on tar's command line to include the quotes.

Come to think of it, get the second part right and the first becomes
redundant.  I'm a belt and suspenders guy, though.  I like redundant.

 
 
 

Using tar with filenames that have blank spaces

Post by Frank Cusac » Fri, 20 Jun 2003 04:46:42




>> I need to create a tar file for each application by reading its files
>> from an inputlist with 100 to 500 items.  Under the Mac OS X system
>> gnutar (1.13) has this option but tar doesn't. The filenames have
>> blank spaces between them and look like this:

>> /Library/Application Support/Application
>> name/Color/Profiles/CIERGB.icc
>> (there are other sub-directories and files under "/Library/Application
>> Support/Application name/"

>> /Users/admin/Library/Preferences/com.apple.nsl.ui
>> (there are other sub-directories and files under
>> "/Users/admin/Library/"

> while read i

well there's your problem.  'read' is space delimited.  Setting IFS to \n
might fix it.

Instead, i would do a find -print0 | xargs -0

/fc

 
 
 

Using tar with filenames that have blank spaces

Post by Stein Arne Storslet » Fri, 20 Jun 2003 22:43:36





>>> I need to create a tar file for each application by reading its files
>>> from an inputlist with 100 to 500 items.  Under the Mac OS X system
>>> gnutar (1.13) has this option but tar doesn't. The filenames have
>>> blank spaces between them and look like this:

>>> /Library/Application Support/Application
>>> name/Color/Profiles/CIERGB.icc
>>> (there are other sub-directories and files under "/Library/Application
>>> Support/Application name/"

>>> /Users/admin/Library/Preferences/com.apple.nsl.ui
>>> (there are other sub-directories and files under
>>> "/Users/admin/Library/"

>> while read i

> well there's your problem.  'read' is space delimited.  Setting IFS to \n
> might fix it.

> Instead, i would do a find -print0 | xargs -0


hello hello
hi hi
now
there

Quote:> do
>   echo "i = $i"
> done < fil

i = hello hello
i = hi hi
i = now
i = there

--
Stein Arne

 
 
 

1. Changing Filenames with Blank spaces.

I want to change many file names with blank spaces and replace
blank spaces with underbar character such examples:
File One   change to   File_One
File Two   change to   File_Two

Here is my script:
for name in `ls *" "*`
do
new=`echo $name | tr " " "_"`
mv $name $new
echo $new
done    

Please advise what is wrong with my script that isnt
working.

--
Posted via CNET Help.com
http://www.help.com/

2. ANN: SourceGear provides cross-platform solutions for SourceSafe

3. Change blank space in Filename

4. NT VNC-kill question

5. Blank space in Filename

6. How to get the information ????

7. Windows shares using samba: problems with blank spaces.

8. lpd filter generating logfiles readable by pac

9. Using sed to delete blank spaces

10. How the *&^!@ do I get tar to tar long filenames?

11. using tar on files with spaces

12. problem using tar on files with spaces

13. CDRW: Having trouble recognizing blank media