Skip to content

Instantly share code, notes, and snippets.

@masonicboom
Created February 19, 2011 05:47
Show Gist options
  • Select an option

  • Save masonicboom/834859 to your computer and use it in GitHub Desktop.

Select an option

Save masonicboom/834859 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script prints each word in $dict_file, one per line.
# $dict_file is a file from http://www.csse.monash.edu.au/~jwb/edict_doc.html.
# See http://www.csse.monash.edu.au/~jwb/jmdict_dtd_h.html to understand why
# <keb> and </keb> are used.
start_marker="<keb>"
end_marker="</keb>"
dict_file=JMdict_e
# This grep-based method will break if any of the "keb" elements in $dict_file
# spans multiple lines.
for line in $(grep $start_marker $dict_file); do
word=${line#$start_marker}
word=${word%$end_marker}
echo $word
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment