Однострочное решение Ruby:
$ ruby -ne 'print $_ if $_.chomp.downcase.scan(/this/).count == 3' < input.txt
How to get This line that this word repeated 3 times in THIS line?
And I will get This line with this here and This one
Работает довольно просто: мы перенаправляем файл на stdin ruby, ruby получает строку от stdin, очищает его с помощью chomp и downcase , и scan().count дает нам количество вхождений подстроки.