#!/bin/bash

IFS="\n"
cp -R  "$oldpath/*" "$newpath/"

I have a script which have to copy folders with spaces and other special characters in their names.

+ cp -R '/home/vmail/user@mail.com/Maildir/.INBOX.Drop.The Host/*' '/home/vmail/user@mail.com/Maildir/.DropThe Host/'
cp: cannot stat `/home/vmail/user@mail.com/Maildir/.INBOX.Drop.The Host/*': No such file or directory

I run it with bash interpreter.

If I manually copy it from the command line with putting the "/home/vmail/user@mail.com/Maildir/.INBOX.Drop.The Host/" in ""-s it works.

  • So what's the question you want answered? – roaima Mar 8 at 9:46
  • apparently what is wrong with the syntax and how to fix it – qlesk Mar 8 at 9:50
  • So please put that in your question, so your question has a question in it. – roaima Mar 8 at 10:05

I can't say that I see the use of setting IFS here.

However, the * is not being expanded since it's within the double quotes. You may want

cp -R  "$oldpath"/* "$newpath"

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.