Last active
November 4, 2015 16:45
-
-
Save natchiketa/bbd4a4cedc091fcf06cb to your computer and use it in GitHub Desktop.
Brain farts (or, things I do seldom enough that I always have to look them up)
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
| # _EMPTY_STRING_ | |
| # The -n operator checks whether the string is not null. Effectively, this will | |
| # return true for every case except where the string contains no characters. ie: | |
| VAR="hello" | |
| if [ -n "$VAR" ]; then | |
| echo "VAR is not empty" | |
| fi | |
| # Similarly, the -z operator checks whether the string is null. ie: | |
| VAR="" | |
| if [ -z "$VAR" ]; then | |
| echo "VAR is empty" | |
| fi | |
| # Note the spaces around the square brackets. Bash will complain if the spaces are not there. | |
| # SOURCE: http://timmurphy.org/2010/05/19/checking-for-empty-string-in-bash/ | |
| # _KILL_PROCESS_BY_NAME_WITH_PS_AND_GREP_ | |
| kill $(ps aux | grep '[p]ython csp_build.py' | awk '{print $2}') | |
| # SOURCE: http://stackoverflow.com/a/3510850/483260 | |
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
| # Unpacking a .deb file without root (i.e. without dpkg) | |
| ar x somefile.deb | |
| tar xzf data.tar.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment