How can I cd into a dir, when it contains spaces, and I need to use it in a script? the directory: /home/user/this is a folder/something normally I would use: cd /home/user/this\ is\ a\ folder/something/ but in a script I cant just add the "\" like: find . -type d | while read FOLDER; do cd $FOLDER; done $ No such file or directory the problem is, that there would be more "special chars" then spaces, "sed" them all? :D Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.centos.org/pipermail/centos/attachments/20090521/edc06c9e/attachment-0004.html>
On Thu, May 21, 2009 at 2:40 PM, Michael Casey <michaelcasey73 at gmail.com> wrote:> How can I cd into a dir, when it contains spaces, and I need to use it in a > script? > > the directory: > /home/user/this is a folder/something > > normally I would use: > cd /home/user/this\ is\ a\ folder/something/ > > but in a script I cant just add the "\" > like: > > find . -type d | while read FOLDER; do cd $FOLDER; done > $ No such file or directoryfind . -type d | while read FOLDER; do cd "$FOLDER"; done should do the trick... -- Marcelo "?No ser? acaso que ?sta vida moderna est? teniendo m?s de moderna que de vida?" (Mafalda)
> How can I cd into a dir, when it contains spaces, and I need to use itin a script? Quote it: cd "/home/user/this is a folder/whatever" -Rob ********************************************************************** This communication contains information which is confidential and may also be legally privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s), disclosure, copying, distribution, or other use of, or action taken or omitted to be taken in reliance upon, this communication or the information in it is prohibited and maybe unlawful. If you have received this communication in error please notify the sender by return email, delete it from your system and destroy any copies. **********************************************************************
yeah, SOLVED: :)) clear; find . -type d | while read FOLDERNAME; do $(cd "$FOLDERNAME"); done Thank you!! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.centos.org/pipermail/centos/attachments/20090521/3508a296/attachment-0004.html>
I used it for this: http://pastebin.ca/1432758 generating m3u files for each subfolder too -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.centos.org/pipermail/centos/attachments/20090524/fc07a31a/attachment-0004.html>