Answer the question
In order to leave comments, you need to log in
How to change folder name when copying?
I write "cp -r mydir anotherdir". In this case, I get "anotherdir/mydir", but how can I make it, for example, get "anotherdir/mydir2" ?
And how can I make it so that if this folder where I copy does not exist, then let it be created (including recursively - there is a folder structure). I know that you can do "mkdir -p dir1 / dir2 / dir3" but if suddenly cp has an option for this, then it would be better to do without an extra command.
Answer the question
In order to leave comments, you need to log in
I write "cp -r mydir anotherdir". In this case, I get "anotherdir/mydir", but how can I make it, for example, get "anotherdir/mydir2" ?
cp -r mydir/* anotherdir/mydir2
find . -regex ".*\.\(jpg\|jpeg\|gif\|png\|JPG\|JPEG\|GIF\|PNG\)" -print0 | xargs -0 cp --parents --target-directory ./tmp/backup
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question