From 0e3cafc48570e4b675ecac11663a5f777b24d339 Mon Sep 17 00:00:00 2001 From: Julian T Date: Tue, 9 Jun 2020 22:59:59 +0200 Subject: Added search scripts --- sem4/hpp/eksamnen/placelinenums.rb | 18 ++++++++++++++++++ sem4/hpp/eksamnen/search.sh | 13 +++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 sem4/hpp/eksamnen/placelinenums.rb create mode 100755 sem4/hpp/eksamnen/search.sh diff --git a/sem4/hpp/eksamnen/placelinenums.rb b/sem4/hpp/eksamnen/placelinenums.rb new file mode 100755 index 0000000..9f43b20 --- /dev/null +++ b/sem4/hpp/eksamnen/placelinenums.rb @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby +require 'open3' +require 'optparse' + +filename = ARGV[0] +outname = ARGV[1] + +page = 1 +File.open(outname, "w") do |out| + File.readlines(filename).each do |line| + if line.start_with? "\xC" + line[0] = '' + page += 1 + end + + out.puts "#{page} #{line}" + end +end diff --git a/sem4/hpp/eksamnen/search.sh b/sem4/hpp/eksamnen/search.sh new file mode 100755 index 0000000..b7b7ed8 --- /dev/null +++ b/sem4/hpp/eksamnen/search.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +if [[ ! -f "superHPP.txt" ]] +then + pdftotext superHPP.pdf +fi + +if [[ ! -f "superHPPindex.txt" ]] +then + ./placelinenums.rb superHPP.txt superHPPindex.txt +fi + +okular -p $(cat superHPPindex.txt | fzf | awk '{print $1}') superHPP.pdf -- cgit v1.2.3