Answer the question
In order to leave comments, you need to log in
Creating folders when copying recursively with cp command in terminal?
When copying a folder with the cp command, how do I make it automatically create folders at the destination I specified? Let me explain with an example:
There is such a command cp -r ~/Local/Test/* ~/Документы/Разные/2021/04/
of Folders Miscellaneous/2021/04/ not at all and I would like them to be created right during copying. So that I do not enter, writes:
cp: cannot create directory '~/Документы/Разные/2021/04': No such file or directory
Answer the question
In order to leave comments, you need to log in
Add to ~/.bashrc
mkcp() {
test -d "${@: -1}" || mkdir -p "${@: -1}"
cp "[email protected]"
}
mkcp -r ~/Local/Test/* ~/Документы/Разные/2021/04/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question