[Gllug] stipping odd { } from a file

Anthony Newman anthony.newman at uk.clara.net
Tue Jan 24 10:16:52 UTC 2006


t.clarke wrote:
> Hehe   - definitely NOT quicker to produce than yr sed script   - except it
> would have probably taken me more time to read up on 'sed' first !!!
> 
> Maybe I should get my reading glasses out?
> 
> But how does sed cope with the requirement to output fresh lines of approx
> 100 chars ??
> 

It doesn't, because you didn't reply to the original question which I 
read afterwards ;-)


cat test \
| perl -e '($string = join //,<>) =~ s/[\{\}\n]//g; $offset=-100; print 
"$newln\n" while $newln = substr($string,$offset+=100,100);'
 > file2.txt


will achieve the desired result in a particularly nasty one-line Perlish 
type of way. It's still not a lot of use AFAICS as the fixed output 
width ignores the position of delimiters in the string, which was not a 
stipulation of the original question (although you inferred it, I am 
pedantic). However, ours is not to reason why :-)


Ant
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list