Jasmine Lognnes Jasmine Lognnes - 5 months ago 39
Ruby Question

Why does gsub in Ruby one liner out hash refs?

Below you see my input file. Why does it output hash refs and not put the input without the


$ cat a
aaah: Administrator
aacp: Administrator
a868: User
1585: User
5053: User
5423: User

$ ruby -pe 'gsub("---\n", '')' a

Answer Source

Your command needs the correct quotations. Should look something like this:

$ ruby -pe 'gsub("---\n", "")' a or $ ruby -pe "gsub('---\n', '')" a

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download