linux cp create folder if not exists code example
Example 1: cp file and create directory if not exists
mkdir -p "$d" && cp file "$d"
Example 2: cp file and create directory if not exists
mkdir -p /foo/bar && cp myfile.txt $_
mkdir -p "$d" && cp file "$d"
mkdir -p /foo/bar && cp myfile.txt $_