my-ruby
1
I was trying to see the how they(-n,-p) works in ruby?
I tried the below :
peter@ubuntu:~$ ruby -np
“hi”
^Z
[2]+ Stopped ruby -np
peter@ubuntu:~$
But the above code taking me to an infinite loop. So my pain point is
how to see that two options functionality?
Thanks
my-ruby
2
On Wed, Feb 13, 2013 at 4:55 PM, Love U Ruby [email protected]
wrote:
I was trying to see the how they(-n,-p) works in ruby?
It will read until EOF.
Cheers
robert
my-ruby
3
Robert K. wrote in post #1096696:
On Wed, Feb 13, 2013 at 4:55 PM, Love U Ruby [email protected]
wrote:
I was trying to see the how they(-n,-p) works in ruby?
It will read until EOF.
Cheers
robert
I didn’t undersatnd, I mean how to return from here. It continues to the
next line for my every “ENTER”
Thanks
my-ruby
4
Robert K. wrote in post #1096709:
On Wed, Feb 13, 2013 at 5:30 PM, Love U Ruby [email protected]
wrote:
I didn’t undersatnd, I mean how to return from here. It continues to the
next line for my every “ENTER”
“Input from a terminal never really ‘ends’ […]”
End-of-file - Wikipedia
Okay! So any other way to test such -n -p options?
Thanks
my-ruby
5
-p
==> assume loop like -n but print line also like sed.
Now I tried below to see how it works :
@ubuntu:~$ ruby -p
hi
\t
-:5: syntax error, unexpected $undefined, expecting $end
@ubuntu:~$
In the above after typing “hi”, when I press ‘ENTER’ got blank
line as above. I thought it would give a output as hi.
Now I tried it a bit different way :
@ubuntu:~$ ruby -p -e '"hi"'
hi
hi
ttt
ttt
\t
\t
But here it seems -p
worked as expected. But the Loop
falls into an
infinite Loop
.
Can anyone help me to understand why these difference?
my-ruby
6
On Wed, Feb 13, 2013 at 5:30 PM, Love U Ruby [email protected]
wrote:
I didn’t undersatnd, I mean how to return from here. It continues to the
next line for my every “ENTER”
“Input from a terminal never really ‘ends’ […]”
Cheers
robert