1 2 3 4 5 6
#!/bin/bash shopt -s extglob echo cp "/${1##file:+(/)}" "${2}" 1>&2 cp "/${1##file:+(/)}" "${2}"