Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Hey, not 100% sure what this error means.
% for f in "*" ; do cp $f ../backup/backup$f ; done cp: ../backup/backup* not found
The purpose is to copy all the files into a folder into a backup folder and rename the files to backup.
The * shouldn't be in quotes:
*
for f in * ; do cp $f ../backup/$f ; done
When you use quotes this prevents the shell from expanding it, so it is looking for a file called *, not all files in the directory which is what you meant.
Add a comment
You are quoting the wrong things: quote the variables, not the wildcards!
% for f in *; do cp "$f" "../backup/$f" ; done
BTW, in this case, you can simply do:
% cp * ../backup/
Or may be this:
cp -b * ../backup
If you want them to be renamed:
% for f in * ; do cp "$f" "../backup/${f}-backup" ; done
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.