Last active
April 11, 2016 20:10
-
-
Save PieterScheffers/437b0a27ff5c36c2bfd1 to your computer and use it in GitHub Desktop.
Random Unix Pieces
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
| # find all lines not beginning with an # | |
| cat somefile | grep -v "^#" | |
| # split all lines to get only the part before the first # | |
| cat somefile | cut -d'#' -f1 | |
| # remove all comments | |
| cat somefile | grep -v "^#" | cut -d'#' -f1 | |
| # List all users | |
| cat /etc/passwd | grep -v "^#" | cut -d':' -f1 | |
| awk -F":" '{print $1}' /etc/passwd | grep -v "^#" | |
| # Remove all files in directory older than | |
| find /path/to/directory/ -mindepth 1 -mtime +5 -delete | |
| # List all groups | |
| cat /etc/group | grep -v "^#" | cut -d':' -f1 | |
| awk -F":" '{print $1}' /etc/group | grep -v "^#" | |
| # add aliases to system wide alias list | |
| echo 'alias pmi "portmaster -ydbg --no-confirm"' >> /etc/csh.cshrc | |
| echo 'alias pmn "echo ' ' && portmaster -L | grep New | cut -d: -f2 | tr -d ' '"' >> /etc/csh.cshrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment