Skip to main content
5 of 5
Salespitch
Chris Davies
  • 128k
  • 16
  • 178
  • 323

You can roll your own command too. Here's a function implementation but you could equally drop a variant of this into an executable script somewhere along your $PATH

mdcopy() {
    mkdir -p -- "$2" &&
        cp -p -- "$1" "$2"
}

Usage

mdcopy /a/b/c/xxxxx.sql /a/b/d/c

An advantage of this approach is that you can have the utility to exactly what you want. This implementation requires a directory as its second argument but you could equally adapt it to expect a file pathname as the second argument. It's whatever works best for you.

Chris Davies
  • 128k
  • 16
  • 178
  • 323