Skip to content

Instantly share code, notes, and snippets.

@prabodh1194
Created May 14, 2023 07:10
Show Gist options
  • Save prabodh1194/b545bcd785d015eeca768b38998c6436 to your computer and use it in GitHub Desktop.
Save prabodh1194/b545bcd785d015eeca768b38998c6436 to your computer and use it in GitHub Desktop.
create full directory path in single command
echo >> $HOME/bin/mktouch << EOF
#!/bin/bash
# This script creates a directory and a file in that location.
# Get the path from the command line argument.
path=$1
# Split the path into the directory and file name.
directory=${path%/*}
file=${path##*/}
# Create the directory.
mkdir -p "$directory"
# Create the file.
touch "$directory/$file"
# Print a message to the user.
echo "The directory '$directory' and the file '$file' have been created."
EOF
@prabodh1194
Copy link
Author

prabodh1194 commented May 14, 2023

This simple command line tool will create the directory and the file in it in one touch. Often times when I am adding test cases, I have this frustrating experience in pycharm where I have to manually create the directory & file manually before I can start writing my tests. This utility has simplified my life drastically.

use it like this:

mktouch path/to/your/file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment