Skip to content

Instantly share code, notes, and snippets.

@eggplants
Last active June 23, 2019 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eggplants/984b8597f868df3f97240cb51a49b4bb to your computer and use it in GitHub Desktop.
Save eggplants/984b8597f868df3f97240cb51a49b4bb to your computer and use it in GitHub Desktop.
cmdでcat -nしたくなったときの
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