Re: Insert a line in a textfile from a script

From: Laurent Vogel (lvl_at_club-internet.fr)
Date: 05/01/03

  • Next message: Phil: "Naming files"
    Date: Thu, 1 May 2003 00:17:19 +0200
    
    

    Micke wrote:
    > I want to insert a new line in a textfile from a script.

    you could try using head and tail if your line is to be inserted in
    a fixed line number.
    For any non trivial case I would use sed (despite what Hyo Joon You
    says, ed is outdated, slow for big files, and there are platforms
    where it is not installed by default anymore).
    the idea is either:

    1) to build a file containing:
      /PATTERN/a\
      your edited line to be appended
    and doing sed -f THIS_FILE_JUST_BUILT
    (problem: the line needs to be edited to replace \ by \\)
    2) else, put the line infile FOO and do
      sed -e '/PATTERN/rfoo'

    If this doesn't suffice please give more details about your specific
    problem.

    Laurent


  • Next message: Phil: "Naming files"

    Relevant Pages

    • Re: Lots of 2s
      ... language. ... But you can read the script and have a good idea of ... I can't make head nor tail of it. ...
      (uk.misc)
    • Check for indexing programatically?
      ... If an encoded file isn't properly indexed, ... the index from a script or program? ... I couldn't make head or tail of it. ...
      (microsoft.public.windowsmedia.sdk)
    • Re: Python Doc Problem Example: os.path.split
      ... I was working on a program where i needed to split a path into dirname, ... > Split the pathname path into a pair, (head, tail) where tail is the ... > last pathname component and head is everything leading up to that. ... > tail part will never contain a slash; if path ends in a slash, ...
      (comp.unix.programmer)
    • Re: Using a link list over an array.
      ... compile (p->data is a void *) so you have not shown us some key ... int cmp ... head = list_sort; ... list_type *tail; ...
      (comp.lang.c)
    • HELP for doubly linked list
      ... forward and one pointing backwards. ... You must be able to insert a new node at the head of the ... You must be able to insert a new node at the tail of the ... tail, F – display contents forward, B – display contents backwards, ...
      (microsoft.public.dotnet.languages.vc)