Linux: copy and create destination dir if it does not exist

bash, cp, linux, shell, unix

Solution

mkdir -p "$d" && cp file "$d"

(there's no such option for `cp`).

Problem

I want a command (or probably an option to cp) that creates the destination directory if it does not exist. Example: ``` cp -? file /path/to/copy/file/to/is/very/deep/there ```

Original source

Related problems