Last active
December 18, 2015 10:49
-
-
Save RyanMcG/5771083 to your computer and use it in GitHub Desktop.
Make the path and a file at once!
This file contains hidden or 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
#!/bin/sh | |
# =================== | |
# touchp -- For Jason | |
# =================== | |
# Copyright © 2013 Ryan McGowan <[email protected]> | |
# This work is free. You can redistribute it and/or modify it under the | |
# terms of the Do What The Fuck You Want To Public License, Version 2, | |
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details. | |
# Because why not... | |
set -e | |
# Get the last argument | |
for last; do true; done | |
# Use the last argument for the call to mkdir. This means that this is not | |
# fully compatible with touch since it only works with one path (or at least it | |
# only creates the directory if it does not already exist for the first path | |
# only). | |
mkdir -p $(dirname $last) | |
# Forward all arguments to touch. | |
touch $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment