Prev: Detect whether a key is being held before script executi
Next: rp_trap_pending/rb_trap_exec in 1.9?
From: Daniel Berger on 13 Apr 2010 18:56 On Apr 13, 11:26 am, Tony Arcieri <tony.arci...(a)medioh.com> wrote: > Another option, utilizing Ruby's mutable strings: > > while line = io.gets > line.slice!(0, 2) > io1.write line > end If you want to avoid temporary files: # Backup your file first, just in case, for testing purposes. require 'mmap' m = Mmap.new('mtp.txt', 'rw') m.gsub!(/^..(.*)/, '\1') m.each{ |line| puts line } m.unmap Regards, Dan
From: Albert Schlef on 13 Apr 2010 21:06 Robert Klemme wrote: > At your favorite shell prompt: > > $ cut -c 3- /home/pt/test/mtp.txt >| /home/pt/test/mtpback.txt Where is ">|" explained? Looks useful. I did "man bash", and I can find about three mentions of ">|" there, but it's not explained. (BTW, removing columns can be done in Vim too, it has a "visual block" mode, which can be entered with Control-v.) -- Posted via http://www.ruby-forum.com/.
From: Seebs on 13 Apr 2010 21:06 On 2010-04-14, Albert Schlef <albertschlef(a)gmail.com> wrote: > Robert Klemme wrote: >> At your favorite shell prompt: >> >> $ cut -c 3- /home/pt/test/mtp.txt >| /home/pt/test/mtpback.txt > Where is ">|" explained? Looks useful. I did "man bash", and I can find > about three mentions of ">|" there, but it's not explained. If the redirection operator is >, and the noclobber option to the set builtin has been enabled, the redirection will fail if the file whose name results from the expansion of word exists and is a regular file. If the redirection operator is >|, or the redirection operator is > and the noclobber option to the set builtin command is not enabled, the redirection is attempted even if the file named by word exists. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Robert Klemme on 14 Apr 2010 01:37 On 14.04.2010 03:06, Albert Schlef wrote: > Robert Klemme wrote: >> At your favorite shell prompt: >> >> $ cut -c 3- /home/pt/test/mtp.txt>| /home/pt/test/mtpback.txt > > Where is ">|" explained? Looks useful. I did "man bash", and I can find > about three mentions of ">|" there, but it's not explained. This is even part of the POSIX standard. I don't have the link handy and I believe you must register with them but reading and downloading the standard is free. > (BTW, removing columns can be done in Vim too, it has a "visual block" > mode, which can be entered with Control-v.) Cool, thanks for the hint! In vi(m) I would probably have used ":%s/^..//". :-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
|
Pages: 1 Prev: Detect whether a key is being held before script executi Next: rp_trap_pending/rb_trap_exec in 1.9? |