Created
May 14, 2023 07:10
-
-
Save prabodh1194/b545bcd785d015eeca768b38998c6436 to your computer and use it in GitHub Desktop.
create full directory path in single command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: