Vim

In Vim count occurrences of match:

:%s/^TDD\d\d:/&/n

Posted in Uncategorized | Leave a comment

Palindate

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)

Posted in Uncategorized | Leave a comment

Grep

Find non-text files:

grep -iR -m 1 g" " | grep "Binary file"

Posted in Uncategorized | Leave a comment

Rename

Recursively change spaces to hyphens in filenames:

find . -name "* *" -print -exec rename "s/ /-/g" {} \;

Posted in Uncategorized | Leave a comment

Awk

List files and directories with sizes:

ls -lF | awk '{printf "%s\t", $5;printf "%s\n",$9}'

or

du -sk * | sort -rn | head -30

Posted in Uncategorized | Leave a comment

File

Find all the symbolic links in a directory:

find /bin/ -name "*" | sort | xargs file -N | grep symbolic | sed 's/ symbolic link to//'

Posted in Uncategorized | Leave a comment

Apropos

Search man page summaries

apropos 'standard input'

Posted in Uncategorized | Leave a comment

Xclip

Copy command-line output to the system clipboard so you can fuck around in a GUI:

cat spock2.txt | xclip -selection clipboard

 

Posted in Uncategorized | Leave a comment

Set

List environment variables in order:

set | awk 'gsub(/(^)[[:upper:]]/,"&") == NF'

 

Posted in Uncategorized | Leave a comment

Cut

Use a comma to delineate fields, print fields 1, 4 and 5:

cut -d, -f 1,4-5 washcit.txt

Posted in Uncategorized | Leave a comment