-e oneliners with File.open 
Author Message
 -e oneliners with File.open

Hi,

I wanted to see how well Vim handles large files, so I entered something
like

ruby -e 'File.open("foo.txt","w") do |f|; f.write 6; end'

(the string to write was different, but the above is enough to reproduce
the error)
but got

-e:1: parse error

This file runs:
-----
File.open("delete.txt", "w") do |file|
   # 100 000 lines with 1 000 xs =~ 100 MB
   file.write((("x"*1000)+"\n")*100000)
end
-----

How to do it with -e in the commandline?

Tobi

--
http://www.*-*-*.com/



Sun, 07 Nov 2004 21:54:24 GMT  
 -e oneliners with File.open

Quote:

> ruby -e 'File.open("foo.txt","w") do |f|; f.write 6; end'

> (the string to write was different, but the above is enough to reproduce
> the error)
> but got

> -e:1: parse error

<SNIP>

end'

6

ruby 1.6.6 (2001-12-26) [i586-linux-gnu]

   # 100 000 lines with 1 000 xs =~ 100 MB
   file.write((("x"*1000)+"\n")*100000)
end'
</SNIP>

Hmm, no problem here... What version are you using?

--
(\[ Kent Dahl ]/)_    _~_    __[ http://www.stud.ntnu.no/~kentda/ ]___/~
 ))\_student_/((  \__d L b__/  NTNU - graduate engineering - 4. year  )
( \__\_?|?_/__/ ) _)Industrial economics and technological management(
 \____/_?_\____/ (____engineering.discipline_=_Computer::Technology___)



Sun, 07 Nov 2004 22:06:00 GMT  
 -e oneliners with File.open
Quote:

> Hi,

> I wanted to see how well Vim handles large files, so I entered something
> like

ruby -e 'File.open("foo.txt","w") do |f|; f.write 6; end'
cat foo.txt
6
Hmmm, works for me.
What version of ruby are you running?

ruby -v
ruby 1.6.6 (2001-12-26) [sparc-solaris2.8]

--
Jim Freeze
If only I had something clever to say for my comment...
~'rc-solaris2.8]



Sun, 07 Nov 2004 22:10:03 GMT  
 -e oneliners with File.open

Quote:
> Hi,

> I wanted to see how well Vim handles large files, so I entered
> something  like

> ruby -e 'File.open("foo.txt","w") do |f|; f.write 6; end'

> (the string to write was different, but the above is enough to
> reproduce  the error)
> but got

> -e:1: parse error

Try swapping the single and double quotes.  Also, you don't need the
semicolons.

--
Jason Voegele
"We believe that we invent symbols. The truth is that they invent us."
    -- Gene Wolfe, The Book of the New Sun



Sun, 07 Nov 2004 22:10:02 GMT  
 -e oneliners with File.open

Quote:
> ruby -e 'File.open("foo.txt","w") do |f|; f.write 6; end'

> -e:1: parse error

Try it without the semi-colon after |f|? I dunno -- your version ran for me
(though I had to flip-flop the single and double quotes to get it through
cmd.com on Windows 2k:

C:\temp>ruby -e 'File.open("foo.txt","w") do |f|; f.write 6; end'
'f' is not recognized as an internal or external command,
operable program or batch file.

C:\temp>ruby -e "File.open('foo.txt','w') do |f|; f.write 6; end"

C:\temp>dir foo.txt
 Volume in drive C is MS-DOS_6
 Volume Serial Number is BCBF-0F2A

 Directory of C:\temp

05/22/2002  09:08a                   1 foo.txt
               1 File(s)              1 bytes
               0 Dir(s)     123,956,736 bytes free

C:\temp>ruby -e "File.open('foo.txt','w') do |f| f.write 6; end"

C:\temp>



Sun, 07 Nov 2004 22:15:16 GMT  
 -e oneliners with File.open

Quote:

> Try swapping the single and double quotes.

works, thx :)

(the aposes need to be escaped for the newline)

ruby -e "open('foo.txt','w') do |f| f.write((('x'*10)+\"\n\")*100) end"

Quote:
> Also, you don't need the
> semicolons.

I know; I just wanted to be friendly to Ruby since it was {*filter*} :)

Tobi

--
http://www.*-*-*.com/



Mon, 08 Nov 2004 01:33:29 GMT  
 -e oneliners with File.open
On Wed, 22 May 2002 13:54:24 GMT,

Quote:

> Hi,

> I wanted to see how well Vim handles large files, so I entered something
> like

Tobi,
you might want to use "vim -n" to suppress creating the swap file.
with this I have no problem opening files in the 130 MB range
very fast.

s.



Mon, 08 Nov 2004 01:45:57 GMT  
 -e oneliners with File.open
Stefan,

Quote:
> you might want to use "vim -n" to suppress creating the swap file.
> with this I have no problem opening files in the 130 MB range
> very fast.

Thanks for the tip :)

What will be missing then? What's the swap file for? Is it for recovery (only)?

Tobi

--
http://www.pinkjuice.com/



Mon, 08 Nov 2004 03:12:39 GMT  
 -e oneliners with File.open
On Wed, 22 May 2002 19:12:39 GMT,

Quote:

> Stefan,

> What will be missing then? What's the swap file for? Is it for recovery (only)?

AFAIK, yes.
But I usually don't edit those files,
I was just looking for something.

s.



Mon, 08 Nov 2004 17:59:17 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. File Open, or not Open, question

2. OPEN(VIEW) without OPEN(FILE)

3. LOGO-L> oneliners and home in mswlogo

4. Opening a file already open

5. Oneliners?

6. Obfuscated oneliner

7. opening existing files with OPEN()

8. opening a file opens it in Notepad

9. opening 'file open' dialog from console

10. multiple use of with-open-file, or with-open-stream

11. opening file vs. opening pipeline on NT.

12. Opening file vs. opening pipeline on NT.

 

 
Powered by phpBB® Forum Software