Check These Out
This is a command that I find myself using all the time. It works like regular grep, but returns the paragraph containing the search pattern instead of just the line. It operates on files or standard input.
$ grepp
or
$ | grepp
Nasty perl one-liner that provides a sparkline of ping times. If you want a different history than the last 30, just put that value in. It (ab)uses unicode to draw the bars, inspired by https://github.com/joemiller/spark-ping . It's not the most bug-free piece of code, but what it lacks in robustness it makes up for in capability. :)
If anyone has any ideas on how to make it more compact or better, I'd love to hear them.
I included a ping to google in the command just as an example (and burned up 10 chars doing it!). You should use it with: $ ping example.com | $SPARKLINE_PING_COMMAND
You could also pipe to logger.
This is N5 sorta like rot13 but with numbers only.
Encrypt
echo "$1" | xxd -p | tr '0-9' '5-90-6'
Decrypt
echo "$1" | tr '0-9' '5-90-6' | xxd -r -p
No need for the ls -r and a sort is also not really needed.
A simple "ls" lists files *and* directories. So we need to "find" the files (type 'f') only.
As "find" is recursive by default we must restrict it to the current directory by adding a maximum depth of "1".
If you should be using the "zsh" then you can use the dot (.) as a globbing qualifier to denote plain files:
zsh> ls *(.) | wc -l
for more info see the zsh's manual on expansion and substitution - "man zshexpn".
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"
}
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
Simple file browser with dmenu, ls, and xdg-open.