Last active
June 23, 2019 22:53
-
-
Save eggplants/984b8597f868df3f97240cb51a49b4bb to your computer and use it in GitHub Desktop.
cmdでcat -nしたくなったときの
This file contains hidden or 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
puts "error!: plz give me argument" if $*[0]==nil | |
exit if $*[0]==nil | |
if $*[1]==nil | |
n=[];(`findstr /N /R ".*" #{$*[0]}`).each_line.map{|a|n<< a} | |
/\d/=~"0";n.map{|b|puts b.sub(/(\d+):/, "#{"%03d" % ($&.to_i+1).to_s} :")} | |
else | |
`findstr /R ".*" #{$*[0]}`.each_line.map{|a|puts a} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment