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

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

26 s
26

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

(there’s no such option for cp).

Leave a Comment