Skip to content

Instantly share code, notes, and snippets.

@rbriank
Created July 9, 2012 18:36
Show Gist options
  • Save rbriank/3078091 to your computer and use it in GitHub Desktop.
Save rbriank/3078091 to your computer and use it in GitHub Desktop.
view partial file with colorized word
# usage:
# sedr 100 120 some/file/with.txt hot
# will return lines 100 to 120 of some/file/with.txt with 'hot' in green
#
alias sedr='ruby -e "start=ARGV.shift;finish=ARGV.shift;filename=ARGV.shift;word=ARGV.shift;cmd=%Q(sed -n #{start},#{finish}p #{filename});cmd << %Q( | sed ''/#{word}/s//`printf "\033[32m#{word}\033[0m"`/'') unless word.nil?; puts cmd; puts %x[#{cmd}];"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment