Check These Out
Check the API. You shouldn't need sed. The print-newline at the end is to prevent zsh from inserting a % after the end-of-output.
Also works with http://v.gd
Print a git log (in reverse order) giving a reference relative to HEAD.
HEAD (the current revision) can also be referred to as HEAD~0
The previous revision is HEAD~1 then HEAD~2 etc.
.
Add line numbers to the git output, starting at zero:
$ ... | nl -v0 | ...
.
Insert the string 'HEAD~' before the number using sed:
$ ... | sed 's/^ \+/&HEAD~/'
.
Thanks to bartonski for the idea :-)
Delete all your branches except master (useful after archiving branches)
Some snippets posted are slow on big dictionaries, this one is fast.
notice what happens when there is more than one unread message in a thread...
also people please dont hardcode the password when you use curl. Leave it out and curl will ask you when it runs. Please...?
My take on the original: even though I like the other's use of -exec echo, sed just feels more natural. This should also be slightly easier to improve.
I expanded this into a script as an exercise, which took about 35 minutes (had to look up some docs): http://bitbucket.org/kniht/nonsense/src/7c1b46488dfc/commandlinefu/quick_image_gallery.py
$_ expands to the last argument of the last command that was executed
Find files that are older than x days in the working directory and list them. This will recurse all the sub-directories inside the working directory.
By changing the value for -mtime, you can adjust the time and by replacing the ls command with, say, rm, you can remove those files if you wish to.
Run netstat as root (via sudo) to get the ID of the process listening on the desired socket.
Use awk to 1) match the entry that is the listening socket, 2) matching the exact port (bounded by leading colon and end of column), 3) remove the trailing slash and process name from the last column, and finally 4) use the system(…) command to call kill to terminate the process.
Two direct commands, netstat & awk, and one forked call to kill.
This does kill the specific port instead of any port that starts with 50. I consider this to be safer.
This command gives a model information of a computer. Also useful in determining the host is a VM machine or actual physical machine.