Taming the tar command: Tips for managing backups in Linux
|
|
|
Comments (7)
Who's crazy idea was it anyway to start using the space character for both an element separator AND a name component? That bad decision has cost humanity lifetimes of wasted effort (not just for Linux users)
Personally whenever I get a file with spaces I immediately replace spaces with underscores. I find that to be a time saving step in the long run.
Personally whenever I get a file with spaces I immediately replace spaces with underscores. I find that to be a time saving step in the long run.
> I get names with quotes
It seems that bash adds the quotes in stdout only, they are not stored in the file names. A GUI file manager does not show any quotes in the file names. tar -tf foo.tar neither.
>lifetimes of wasted effort...replace spaces with underscores
Yep, right or wrong, I agree, and do same.
It seems that bash adds the quotes in stdout only, they are not stored in the file names. A GUI file manager does not show any quotes in the file names. tar -tf foo.tar neither.
>lifetimes of wasted effort...replace spaces with underscores
Yep, right or wrong, I agree, and do same.
Seen elsewhere, posted by someone who's not me:
...but I happily snarfed it to disk and called it ".space2bar" (dotted name so it doesn't show up in an Apache index of the subdir where I use it).
for file in *; do mv "$file" `echo $file | tr ' ' '_'` ; done
Another possibility, in Bash:
Should also work in ksh. IIRC, ksh had it first.
$ for file in * ; do mv "$file" ${file/ /_} ; done>for file in * ; do mv "$file" ${file/ /_} ; done
This would replace the first space only.
for file in * ; do mv "$file" ${file// /_} ; done
replaces all spaces;
This would replace the first space only.
for file in * ; do mv "$file" ${file// /_} ; done
replaces all spaces;
Woops, yup, you're right.
"Many eyes", indeed.
"Many eyes", indeed.
Post a comment
A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.
Your message:Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help
Sign up and post (it is free) or Log in and post

Lots of music files and directories are that way. For example, on my server my mp3 directory has a sub-directory David Garrett/.
The command "cp -r mp3 /foo/" works correctly -- I get, among other things /foo/mp3/David Garrett/
But when I tar the mp3 directory and then un-tar it under /foo, I get names with quotes in them, e.g., /foo/mp3/'David Garret'/. "scp" does the same thing -- the command "scp -r mp3 someone@somehost/foo/" creates somehost/foo/'David Garret'/ -- again with quotes.
How do I fix this (mis-)behavior?