![]() |
|
|
|||
|
manage blankspaces in filenames
#pwd
/home/user/My Slack Packs/source #ls test.tar.gz #CWD=pwd #echo $CWD /home/user/My Slack Packs/source #tar xzf $CWD/test.tar.gz tar: /home/user/My: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: Child returned status 2 tar: Slack: Not found in archive tar: Packs/test.tar.gz: Not found in archive tar: Error exit delayed from previous errors Is there a solution to use tar with variables containing filenames with blankspaces? |
|
|||
|
Re: manage blankspaces in filenames
On 2008-07-13, heavytull wrote:
> #pwd > /home/user/My Slack Packs/source > #ls > test.tar.gz > #CWD=pwd > #echo $CWD > /home/user/My Slack Packs/source The result of those last two commands would be: #CWD=pwd #echo $CWD pwd The current directory is kept in the variable $PWD. > #tar xzf $CWD/test.tar.gz > tar: /home/user/My: Cannot open: No such file or directory > tar: Error is not recoverable: exiting now > tar: Child returned status 2 > tar: Slack: Not found in archive > tar: Packs/test.tar.gz: Not found in archive > tar: Error exit delayed from previous errors > > Is there a solution to use tar with variables containing filenames with > blankspaces? tar xzf "$PWD/test.tar.gz" -- Chris F.A. Johnson, author | <http://cfaj.freeshell.org> Shell Scripting Recipes: | My code in this post, if any, A Problem-Solution Approach | is released under the 2005, Apress | GNU General Public Licence |
|
|||
|
Re: manage blankspaces in filenames
heavytull <heavytull@hotmail.com> writes:
>#pwd >/home/user/My Slack Packs/source >#ls >test.tar.gz >#CWD=pwd >#echo $CWD >/home/user/My Slack Packs/source >#tar xzf $CWD/test.tar.gz >tar: /home/user/My: Cannot open: No such file or directory >tar: Error is not recoverable: exiting now >tar: Child returned status 2 >tar: Slack: Not found in archive >tar: Packs/test.tar.gz: Not found in archive >tar: Error exit delayed from previous errors >Is there a solution to use tar with variables containing filenames with >blankspaces? A) Bad idea. B) Since you in /home/user/My Slack Packs/source why not just do tar xzf test.tar.gz C) Try tar xzf "$CWD/test.tar.gz" d) It is a very bad idea to use filenames which spaces. Why are you doing so? |
|
|||
|
Re: manage blankspaces in filenames
On 13 Jul 2008 20:19:19 GMT, heavytull <heavytull@hotmail.com> wrote:
>#pwd >/home/user/My Slack Packs/source >#ls >test.tar.gz >#CWD=pwd >#echo $CWD >/home/user/My Slack Packs/source > >#tar xzf $CWD/test.tar.gz >tar: /home/user/My: Cannot open: No such file or directory >tar: Error is not recoverable: exiting now >tar: Child returned status 2 >tar: Slack: Not found in archive >tar: Packs/test.tar.gz: Not found in archive >tar: Error exit delayed from previous errors > >Is there a solution to use tar with variables containing filenames with >blankspaces? use a back slash before the space - /home/user/My\ Slack\ Packs/source this escape character works for any character that gets confused on the command line. (not just spaces) |
|
|||
|
Re: manage blankspaces in filenames
Unruh <unruh-spam@physics.ubc.ca> wrote:
> d) It is a very bad idea to use filenames which spaces. No, there's nothing wrong with using spaces in file names. It's a very bad idea to assume that file names don't contain white spaces. Florian -- <http://www.florian-diesch.de/> ----------------------------------------------------------------------- ** Hi! I'm a signature virus! Copy me into your signature, please! ** ----------------------------------------------------------------------- |
|
|||
|
Re: manage blankspaces in filenames
Florian Diesch <diesch@spamfence.net> writes:
>Unruh <unruh-spam@physics.ubc.ca> wrote: >> d) It is a very bad idea to use filenames which spaces. >No, there's nothing wrong with using spaces in file names. It's a very >bad idea to assume that file names don't contain white spaces. As you know, a space has a special meaning to the shell-- it is the "word delimiter" to use something which means something spacial like that in the filename is simply asking for trouble. Would you also put single quotes into a file name, or backspaces, or semicolonsi or backslashes, all of which have special meanings? While there are ways of getting around it, it is just plain idiotic to use those things in filenames. > Florian >-- ><http://www.florian-diesch.de/> >----------------------------------------------------------------------- >** Hi! I'm a signature virus! Copy me into your signature, please! ** >----------------------------------------------------------------------- |
|
|||
|
Re: manage blankspaces in filenames
Unruh wrote:
> Florian Diesch <diesch@spamfence.net> writes: > >> Unruh <unruh-spam@physics.ubc.ca> wrote: > > >>> d) It is a very bad idea to use filenames which spaces. > >> No, there's nothing wrong with using spaces in file names. It's a very >> bad idea to assume that file names don't contain white spaces. > > As you know, a space has a special meaning to the shell-- it is the "word > delimiter" to use something which means something spacial like that in the > filename is simply asking for trouble. Would you also put single quotes > into a file name, or backspaces, or semicolonsi or backslashes, all of which have special > meanings? While there are ways of getting around it, it is just plain > idiotic to use those things in filenames. There is nothing wrong in using spaces in file names, it's just anoying, but as people eare used to use spaces in the file names from microsoft, so it's better to use quotes around file names, this way it will work regardless if there is spaces or not. Chris did point this out in the first reply. -- //Aho |
|
|||
|
Re: manage blankspaces in filenames
Unruh <unruh-spam@physics.ubc.ca> wrote:
> Florian Diesch <diesch@spamfence.net> writes: > >>Unruh <unruh-spam@physics.ubc.ca> wrote: > >>> d) It is a very bad idea to use filenames which spaces. > >>No, there's nothing wrong with using spaces in file names. It's a very >>bad idea to assume that file names don't contain white spaces. > > As you know, a space has a special meaning to the shell-- it is the "word > delimiter" to use something which means something spacial like that in the > filename is simply asking for trouble. No. With some basic shell knowledge that's no problem. > Would you also put single quotes > into a file name, or backspaces, or semicolonsi or backslashes, all of which have special > meanings? Backspace isn't printable so it usually doesn't make much sense to use it in filenames. The other characters are fine. diesch@scenic:~% locate \ |wc 6462 34949 445299 diesch@scenic:~% locate \;|wc 26 36 2001 diesch@scenic:~% locate \'|wc 5741 9488 336916 diesch@scenic:~% locate \`|wc 70 79 3377 diesch@scenic:~% locate \"|wc 41 446 4427 diesch@scenic:~% locate \\|wc 0 0 0 > While there are ways of getting around it, it is just plain > idiotic to use those things in filenames. The Ubuntu maintainers don't see any problem with spaces in filenames, too: diesch@scenic:~% locate \ |grep -v home|wc 112 289 7622 Florian -- <http://www.florian-diesch.de/> ----------------------------------------------------------------------- ** Hi! I'm a signature virus! Copy me into your signature, please! ** ----------------------------------------------------------------------- |
|
|||
|
Re: manage blankspaces in filenames
Florian Diesch <diesch@spamfence.net> writes:
>Unruh <unruh-spam@physics.ubc.ca> wrote: >> Florian Diesch <diesch@spamfence.net> writes: >> >>>Unruh <unruh-spam@physics.ubc.ca> wrote: >> >>>> d) It is a very bad idea to use filenames which spaces. >> >>>No, there's nothing wrong with using spaces in file names. It's a very >>>bad idea to assume that file names don't contain white spaces. >> >> As you know, a space has a special meaning to the shell-- it is the "word >> delimiter" to use something which means something spacial like that in the >> filename is simply asking for trouble. >No. With some basic shell knowledge that's no problem. >> Would you also put single quotes >> into a file name, or backspaces, or semicolonsi or backslashes, all of which have special >> meanings? >Backspace isn't printable so it usually doesn't make much sense to >use it in filenames. The other characters are fine. >diesch@scenic:~% locate \ |wc > 6462 34949 445299 >diesch@scenic:~% locate \;|wc > 26 36 2001 >diesch@scenic:~% locate \'|wc > 5741 9488 336916 >diesch@scenic:~% locate \`|wc > 70 79 3377 >diesch@scenic:~% locate \"|wc > 41 446 4427 >diesch@scenic:~% locate \\|wc > 0 0 0 >> While there are ways of getting around it, it is just plain >> idiotic to use those things in filenames. >The Ubuntu maintainers don't see any problem with spaces in >filenames, too: >diesch@scenic:~% locate \ |grep -v home|wc > 112 289 7622 I maintain my position. It is just plain idiotic to sue those things in filenames. |
|
|||
|
Re: manage blankspaces in filenames
On Sat, 19 Jul 2008 18:50:06 +0200, J.O. Aho wrote:
> There is nothing wrong in using spaces in file names, it's just anoying, > but as people eare used to use spaces in the file names from microsoft, > so it's better to use quotes around file names, this way it will work > regardless if there is spaces or not. > > Chris did point this out in the first reply. that's not because of microsoft that i'm using spaces. for very long I have never used spaces, i just recently chose to use blanks, because it looks good and unix filenames accepts the use of it. |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|