Table of Contents

Scripts

HDHomeRun

MythTV

See Transcode

bash

$ ls
fotc.101.avi

$ for i in *.avi; do mv "$i" "the.flight.of.the.conchords${i/fotc/}"; done

$ ls
the.flight.of.the.conchords.101.avi
$ ls
dexter.S01E01.Dexter.DVDRip.XviD-SAiNTS.avi

$ rename 'y/A-Z/a-z/' *

$ ls
dexter.s01e01.dexter.dvdrip.xvid-saints.avi

$ rename 's/dexter.dvdrip.xvid-saints.//' *

$ ls
dexter.s01e01.avi

gawk

Say you have a text file containing columns and you want to do a search through the file for given column values. Let's assume the third column contains IP addresses and the sixth column contains port numbers. To find all the activity from IP “10.0.0.1” on port “1234”, you could do the following:

$ gawk '{if($3 == "10.0.0.1" && $6 == "1.2.3.4"){print $0}}' /path/to/file | less

vi

Remove Control Characters

:%s/^M//g

Explanation:

  • % sets a range of the entire files
  • s/…/…/ is standard vi search-and-replace
    • In our example, we're searching for ^M and replacing with nothing
    • To create the ^M, you must actually type ^V^M as ^V is used to create control characters in Unix.
  • g sets the command globally (replacing all occurrences)

ssh

Port Forwarding

$ ssh -L 9999:dustin.homeip.net:80 dustin.homeip.net
http://localhost:9999/
scripts.txt · Last modified: 2010/01/17 05:30 UTC by dustin