Hi all,
I am new to Ruby. I just wonder how I can concatenate all the lines from
one file and let them become one string.
Thanks,
Li
Hi all,
I am new to Ruby. I just wonder how I can concatenate all the lines from
one file and let them become one string.
Thanks,
Li
Li Chen wrote:
I am new to Ruby. I just wonder how I can concatenate all the lines from
one file and let them become one string.
File.read("/path/to/file")
David V.
On Mon, Oct 09, 2006 at 03:36:43AM +0900, Li Chen wrote:
Hi all,
I am new to Ruby. I just wonder how I can concatenate all the lines from
one file and let them become one string.
How about:
a=File.open("/home/n6tadam/.xsession").read.gsub!(’\n’, ’ ')
I’ve substituted the newlines for spaces – but you can do whatever you
want with it.
– Thomas A.
Or maybe
File.readlines(“xorg.conf”).join(’ ‘).gsub!("\n",’ ')
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs