User agnostic terminal commands
I'm trying to create a directory, and user agnostic command.
How can this be done? i.e. /test1/Longeron/test.txt or /test1/ANYUSERHERE/text.txt I'm basically looking for some kind of way to insert the current user in the place of some placeholder. |
$USER variable
Code:
lm ~ # mkdir $USER |
Wow. So obvious. Thank you!
|
Please note that if you're going to do that you should "anchor" the directory to be created in a sensible location like /tmp or /var/tmp (not "/" or other top level directories), ensure the variable isn't messed with or empty, in short: watch your error handling. Also if these are temporary directories consider using mktemp instead.
Code:
# Empty variable or way too short user name: |
All times are GMT -5. The time now is 12:57 AM. |