zshell: cp the last file in a given directory

in code

It’s come in useful for some small tasks.

cp-last() {
    if [[ -d "$1" ]]; then
        echo "cd: ${1}: Not a directory"
        exit 1

    cp "${1}/$(ls -A1t $1 | head -n 1)" "${2}"

A Summer of Running

in running

Achill Half Marathon

in running

Your email address will not be published. Required fields are marked *