In Vim count occurrences of match:
:%s/^TDD\d\d:/&/n
Palindromic ISO dates between two years with #Python
#!/usr/bin/python3
import sys
from datetime import datetime
from itertools import chain
def palinDay(y):
s = str(y)
r = s[::-1]
iso = '-'.join([s, r[0:2], r[2:]])
try:
datetime.strptime(iso, '%Y-%m-%d')
return [iso]
except ValueError:
return []
palinDates = list(chain.from_iterable(
map(palinDay, range(int(sys.argv[1]),int(sys.argv[2])))
))
for x in [
"\n".join(palinDates),
]:
print(x)
Recursively change spaces to hyphens in filenames:
find . -name "* *" -print -exec rename "s/ /-/g" {} \;
List files and directories with sizes:
ls -lF | awk '{printf "%s\t", $5;printf "%s\n",$9}'
or
du -sk * | sort -rn | head -30
Find all the symbolic links in a directory:
find /bin/ -name "*" | sort | xargs file -N | grep symbolic | sed 's/ symbolic link to//'
Copy command-line output to the system clipboard so you can fuck around in a GUI:
cat spock2.txt | xclip -selection clipboard