sed question - Unix

This is a discussion on sed question - Unix ; Hi I want to append after the last line of a number of files file$i.mod the following line: display _solve_user_time; using sed. What would the sed command look like in the following script? #!/bin/sh for i in `seq 1 100` ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: sed question

  1. sed question

    Hi

    I want to append after the last line of a number of files file$i.mod
    the following line:

    display _solve_user_time;

    using sed.

    What would the sed command look like in the following script?

    #!/bin/sh
    for i in `seq 1 100`
    do
    sed ??????? file$i.mod
    done

    Thanks
    Dieter
    --
    Dieter Kraft
    Munich University of Applied Sciences
    Department of Mechanical Engineering
    dieter.kraft@fhm.edu
    www.lrz-muenchen.de/~dkraft

  2. Re: sed question

    Dieter Kraft wrote:

    > Hi
    >
    > I want to append after the last line of a number of files file$i.mod
    > the following line:
    >
    > display _solve_user_time;
    >
    > using sed.
    >
    > What would the sed command look like in the following script?
    >
    > #!/bin/sh
    > for i in `seq 1 100`
    > do
    > sed ??????? file$i.mod
    > done
    >
    > Thanks
    > Dieter


    Why would you want to use "sed" instead of "printf" to add a line to the
    end of a file?

    Ed.

  3. Re: sed question

    Ed Morton wrote:
    > Dieter Kraft wrote:
    >
    >> Hi
    >>
    >> I want to append after the last line of a number of files file$i.mod
    >> the following line:
    >>
    >> display _solve_user_time;
    >>
    >> using sed.
    >>
    >> What would the sed command look like in the following script?
    >>
    >> #!/bin/sh
    >> for i in `seq 1 100`
    >> do
    >> sed ??????? file$i.mod
    >> done
    >>
    >> Thanks
    >> Dieter

    >
    > Why would you want to use "sed" instead of "printf" to add a line to the
    > end of a file?
    >
    > Ed.

    How would this work with printf?

    --
    Dieter Kraft
    Munich University of Applied Sciences
    Department of Mechanical Engineering
    dieter.kraft@fhm.edu
    www.lrz-muenchen.de/~dkraft

  4. Re: sed question

    Dieter Kraft wrote:

    > Ed Morton wrote:
    >
    >> Dieter Kraft wrote:
    >>
    >>> Hi
    >>>
    >>> I want to append after the last line of a number of files file$i.mod
    >>> the following line:
    >>>
    >>> display _solve_user_time;
    >>>
    >>> using sed.
    >>>
    >>> What would the sed command look like in the following script?
    >>>
    >>> #!/bin/sh
    >>> for i in `seq 1 100`
    >>> do
    >>> sed ??????? file$i.mod
    >>> done
    >>>
    >>> Thanks
    >>> Dieter

    >>
    >>
    >> Why would you want to use "sed" instead of "printf" to add a line to
    >> the end of a file?
    >>
    >> Ed.

    >
    > How would this work with printf?
    >


    printf "display _solve_user_time;\n" >> "file$i.mod"

    Ed.

  5. Re: sed question

    Ed Morton wrote:

    > Dieter Kraft wrote:
    >
    >> Ed Morton wrote:
    >>
    >>> Dieter Kraft wrote:
    >>>
    >>>> Hi
    >>>>
    >>>> I want to append after the last line of a number of files file$i.mod
    >>>> the following line:
    >>>>
    >>>> display _solve_user_time;
    >>>>
    >>>> using sed.
    >>>>
    >>>> What would the sed command look like in the following script?
    >>>>
    >>>> #!/bin/sh
    >>>> for i in `seq 1 100`
    >>>> do
    >>>> sed ??????? file$i.mod
    >>>> done
    >>>>
    >>>> Thanks
    >>>> Dieter
    >>>
    >>>
    >>>
    >>> Why would you want to use "sed" instead of "printf" to add a line to
    >>> the end of a file?
    >>>
    >>> Ed.

    >>
    >>
    >> How would this work with printf?
    >>

    >
    > printf "display _solve_user_time;\n" >> "file$i.mod"
    >
    > Ed.


    I just noticed the #!/bin/sh at the top of your script, so IF you don't
    have printf in your shell, use echo:

    echo "display _solve_user_time;" >> "file$i.mod"

    Ed.

+ Reply to Thread