bigsid has asked for the wisdom of the Perl Monks concerning the following question:

I have a file that contains: 123456:89 then more stuff abcdef:gh yet more stuff
  • Comment on How do I delete the first 9 characters of each line in a file

Replies are listed 'Best First'.
Re: How do I delete the first 9 characters of each line in a file
by ehdonhon (Curate) on May 20, 2002 at 22:54 UTC
    perl -pi.bak -e 's/^.{0,9}//' filename.here

    Minor tweak per owner - dvergin 2002-05-21

Re: How do I delete the first 9 characters of each line in a file
by jmcnamara (Monsignor) on May 20, 2002 at 22:58 UTC
    The following two methods are equivalent:
    perl -lpe 'substr $_, 0, 9, ""' file perl -lpe '$_ = substr $_, 9' file

    If you want to edit the file in-place you can add the -i switch:

    # Edited in-place perl -i -lpe 'substr $_, 0, 9, ""' file # Edited in-place with back-up perl -i.bak -lpe 'substr $_, 0, 9, ""' file
Re: How do I delete the first 9 characters of each line in a file
by particle (Vicar) on May 20, 2002 at 22:27 UTC
    perl -lne"print $_=~/.........(.*)/" your files here