pv enwiki.xml | grep -C1 ‘<title>’ | tr -d ‘ ‘ | sed ‘s/<title>//’ | sed ‘s/</title>//’ |  

sed ‘s/<id>//’ | sed ‘s/</id>//’ | sed ‘s/<page>//’  | tr -d ‘ ‘ | grep -v ‘^$’ | 
tr ‘n’ ‘t’ | tr ‘-’ ‘n’ | grep -v ‘^$’ > title_id.txt 

I know it’s probably as efficient as spaghetti code is – but hey! It works and does what I want it to!

Tagged with:
 

One Response to Probably, the most horrible UNIX command I've ever written

  1. Roman Kirillov says:

    The command was corrected to:pv enwiki.xml | grep -C1 ” | sed ‘s///’ | sed ‘s/<\/title>//’ | sed ‘s/<id>//’ | sed ‘s/<\/id>//’ | sed ‘s/<page>//’ | tr ‘\n’ ‘\t’ | tr ‘-’ ‘\n’ | grep -v ‘^$’ > title_id.txt

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">