• 1
watch -n 1 "netstat -ntu | sed '1,2d' | awk '{ print \$6 }' | sort | uniq -c | sort -k 2" · 2011-09-30 09:04:14 ### What's this? commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down. ### Check These Out Which processes are listening on a specific port (e.g. port 80) swap out "80" for your port of interest. Can use port number or named ports e.g. "http" Which processes are listening on a specific port (e.g. port 80) swap out "80" for your port of interest. Can use port number or named ports e.g. "http" Get the SUM of visual blocked digits in vim Quick access to the ascii table. escape any command aliases e.g. if rm is aliased for 'rm -i', you can escape the alias by prepending a backslash: rm [file] # WILL prompt for confirmation per the alias \rm [file] # will NOT prompt for confirmation per the default behavior of the command Export MySQL tables that begin with a string ensure your ssh tunnel will always be up (add in crontab) I find it ugly & sexy at the same time isn't it ? Convert seconds to [DD:][HH:]MM:SS Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Delete all empty lines from a file with vim

Copy all files, including hidden files, recursively without traversing backward
You could do the following, however, brace expansion with {} is not defined in POSIX, and therefore not guaranteed to work in all shells. But, if it does, it's more convenient (although it's certainly not less typing): \$ cp -r {*,.??*} /dest Sometimes there are times when I need to cp(1), mv(1) or rm(1) files recursively, but don't want to traverse the previous directory by following ../../../../ etc out of the current directory. This command prevents that. The secret sauce is ".??*". The file globbing ensures that it must start with a dot, and be followed by at least two characters. So, three characters must exist in the filename, which eliminates "." and "..".