Tag Archives: path

Python: Create directory

Simple Python snippet which creates a directory if it doesn’t exist. #! /usr/bin/env python import os   # create directory "mydir" if it doesn’t exist already os.path.exists("mydir") or os.mkdir("mydir")

Posted in <code> | Tagged , , , , , | Leave a comment

Bash: Use pathmunge to manage your PATH

Simplify your bash PATH management with pathmunge. The pathmunge will add a directory to the beginning of your PATH if it is missing from your PATH. This means that you can safely .source ~/.bashrc without ending up with duplicate folders in your path (which you would get if you had used export PATH=/add/this/dir:$PATH). It is also clearer what folders you … Continue reading

Posted in <code> | Tagged , , , , , , | Leave a comment

Basename and Dirname

Often the unix commands basename and dirname are useful in shell scripts, but how do you use these in c or c++?. The C way: libgen.h If you’re working in c, the posix header libgen.h provides dirname and basename functions, with some limitations: They only work with char *, and dirname will modify the char * you pass into it … Continue reading

Posted in <code> | Tagged , , , , , , , , , | Leave a comment
<RSS Feed>