
maybe we can give'm a potje tipex? On Fri, 18 Jul 2008, Elisabeth Wischnitzki wrote:
and the full python version:
#!/usr/bin/env python
import sys
fhd = open(sys.argv[1]).readlines() fw = open(sys.argv[2], "w") n = int(sys.argv[3])
for line in fhd: fw.write(line[n:len(line)])
Kenny Billiau wrote:
the full perl solution:
#!perl
open IN, "<${ARGS[0]}"; open OUT, ">${ARGS[1]}"; my $n = $ARGS[2];
while (<IN>) { print OUT substr $_,$n; }
And yes .. it's shorter ;)
On Fri, 18 Jul 2008, Michiel Van Bel wrote:
ok, here is the full java code:
class ReduceFile{ public static void main(String[] args) throws Exception{ BufferedReader reader = new BufferedReader(new FileReader(new File(args[0]))); BufferedWriter writer = new BufferedWriter(new FileWriter(new File(args[1]))); int length = Integer.parseInt(args[2]); String s = reader.readLine(); while(s!=null){ writer.write(s.substring(length,s.length())+"\n"); s = reader.readLine(); } reader.close(); writer.close(); } }
Then execute with : "java ReduceFile fileIn fileOut n"
Cannot be simpler... (though i agree that java is quite a verbose language compared to perl)
Michiel
Ward Blond� wrote:
I tried both with the same result.
Ward
your in and outfile have to different, sed is a StreamEDitor .. or also > known as the ShrEDder ;) It's mostly harmless tho,
Kenny On Fri, 18 Jul 2008, Ward Blond� wrote: > > > Thanks for all the answers. I tried this 'sed' method of Kenny but it > > reduces my file to the characterless file. I 'll try something else. > > Ward > > Kenny Billiau wrote: > apparently, you also have to escape the {} in tcsh .. so the sed > > > solution > becomes: > > > > sed "s/^.\{,2\}\(.*\)//" infile > outfile > > > > (djeezes) > > > > -Kenny > > > > On Fri, 18 Jul 2008, Ward Blond� wrote: > > > > > > > I have no problems with VI, but I don't understand the > > > answer: the > number n doesn't occur in it!? > > > Ward > > > > Sofie Van Landeghem wrote: > > > Oh, gaan we in VI beginnen, ik doe alles in java hoor :p > > > > > Kenny Billiau wrote: > > > > In VI you can do: > > > > > <esc>gg<ctrl+v>Gd > > > > > > the sequences between <> are key you have to
Kenny Billiau wrote: press .. :)
> > > > > On Fri, 18 Jul 2008, Ward Blond� wrote: > > > > > > > > > > Hoi Binaries, > > > > > > > Does anyone know a nice method to strip the first n > > > > > characters away > > from every line in a file? > > > > > > > Ward > > > > > _______________________________________________ > > > > > Binari Is Not A Regular Island > > > > > Binari@psb.ugent.be > > > > > https://maillist.psb.ugent.be/mailman/listinfo/binari > > > > > > > > > > > > > >
> > > > > > > > > > _______________________________________________ > > > > Binari Is Not A Regular Island > > > > Binari@psb.ugent.be > > > > https://maillist.psb.ugent.be/mailman/listinfo/binari > > > > > > > > > >
> > > > > > > _______________________________________________ > Binari Is Not A Regular Island > Binari@psb.ugent.be > https://maillist.psb.ugent.be/mailman/listinfo/binari > > > > > > > > >
_______________________________________________ Binari Is Not A Regular Island Binari@psb.ugent.be https://maillist.psb.ugent.be/mailman/listinfo/binari
------------------------------------------------------------------------
_______________________________________________ Binari Is Not A Regular Island Binari@psb.ugent.be https://maillist.psb.ugent.be/mailman/listinfo/binari
--