$ echo 'mkfile() { mkdir -p "$(dirname "$1")" && touch "$1" ; }' >> ~/.bashrc $ source ~/.bashrc $ mkfile /your/directory/yourFile.txt