October archive

lines only in a single file

With sorted file1 and file2, shows lines in file1 which have no corresponding line in file2:

comm -2 -3 file1 file2

selective field printing with awk

You have a tab-delimited file and only want certain fields.

awk 'BEGIN{OFS=FS="\t"}{print $3,$4 }' ipa_uni_test.txt

Important things:

  • FS is the "field separator", so it could be "," or similar instead of "\t"
  • OFS is the "output field separator". This replaces the ',' in the print statement.
  • $3 is a positional variable; it's the 3rd field.

Printing an e-book for binding

Tools: pdftk, pdfjam.

Rearrange pages from the source file:

pdftk latin-out.pdf cat 1 1-317 1 1 output latin-fixed.pdf

Split the source file:

pdftk latin-fixed.pdf cat 1-16 output 016.pdf ... pdftk latin-fixed.pdf cat 305-320 output 320.pdf

Fuck, a page was duplicated in the source. Find another file which has it and blend it in:

pdftk A=latin-fixed.pdf B=anthologyoflatin00tyrrrich_bw.pdf cat A145 B154 A147-160 output 160-new.pdf

Generate some commands in python for easy copy-pasting.

for x in range(16, 324, 16): print "pdfbook --short-edge --signature '16' %03d.pdf" % (x,)

Run the commands:

pdfbook --short-edge --signature '16' 016.pdf ... pdfbook --short-edge --signature '16' 320.pdf