Created
July 9, 2012 18:36
-
-
Save rbriank/3078091 to your computer and use it in GitHub Desktop.
view partial file with colorized word
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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