Skip to content

Instantly share code, notes, and snippets.

@hyamamoto
Created July 13, 2016 08:27
Show Gist options
  • Save hyamamoto/604a007301b05e76e0251a759c5b682e to your computer and use it in GitHub Desktop.
Save hyamamoto/604a007301b05e76e0251a759c5b682e to your computer and use it in GitHub Desktop.
A script to obtain HTML document from the `ack` search result. (just a proof of concept)
#!/bin/sh
##############################
# ack_2_html (script example)
##############################
# Description:
# Perform an ack search then create a colorized HTML document.
# Usage:
# ack_2_html.sh OUTPUTFILE_NAME PART_OF_FILEPATH PART_OF_TEXT
# Dependency:
# expect, ansifilter, ack
target_dir=.
file=results/$1
file_query=$2
text_query=$3
mkdir -p results
find ${target_dir} | grep ${file_query} > ${file}.lst
unbuffer -p ack --files-from=${file}.lst ${text_query} | tee ${file}.txt
ansifilter -i ${file}.txt --html --doc-title "ack_2_html: ${file}" > ${file}.html
open ${file}.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment