How to write at specific loaction in a file

Discussion in 'Perl Misc' started by Pioneer, Aug 17, 2005.

  1. Pioneer

    Pioneer Guest

    Hi,

    I have to write some text in a file keeping the previous content as it
    is.

    e.g.
    $ cat file1
    abc
    qwe

    I want the o/p as
    $ cat file1
    abc
    123
    qwe

    I want to write 123 at second line. "open" command with > and >>
    options either overwrites or appends at the end.

    Thanks in advance
    Pioneer
    Pioneer, Aug 17, 2005
    #1
    1. Advertising

  2. Pioneer wrote:
    > I have to write some text in a file keeping the previous content as it
    > is.
    >
    > e.g.
    > $ cat file1
    > abc
    > qwe
    >
    > I want the o/p as
    > $ cat file1
    > abc
    > 123
    > qwe


    perldoc -q "insert a line"

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Aug 17, 2005
    #2
    1. Advertising

  3. Pioneer

    Pioneer Guest

    Thanks for the reply but i dont have perldoc installed on our server.
    Pioneer
    Pioneer, Aug 17, 2005
    #3
  4. Pioneer

    Paul Lalli Guest

    Please quote some context when replying. Please reading the Posting
    Guidelines for this group.

    Pioneer wrote:
    > Thanks for the reply but i dont have perldoc installed on our server.
    > Pioneer


    The perldocs are available online as well, at http://www.perldoc.com

    http://www.perldoc.com/perl5.8.4/pod/perlfaq.html
    search for the phrase suggested in the previous post.

    Paul Lalli
    Paul Lalli, Aug 17, 2005
    #4
  5. Pioneer

    Matt Garrish Guest

    "Pioneer" <> wrote in message
    news:...
    > Thanks for the reply but i dont have perldoc installed on our server.
    > Pioneer
    >


    http://www.perldoc.com/

    Matt
    Matt Garrish, Aug 17, 2005
    #5
  6. Pioneer wrote:
    > Thanks for the reply


    What reply? Please quote appropriate context as has been customary for 20
    years such that people have a chance to know what you are talking about.

    > but i dont have perldoc installed


    Then I suggest you fix this broken Perl installation.

    > on our server.


    Well, ok, as people don't develop on servers. Maybe you don't need to fix
    it. But what about you development machines? Do they have broken
    installations, too?

    > Pioneer


    The true pioneer succeeds because he does not repeat the mistakes that
    others already made.

    jue
    Jürgen Exner, Aug 17, 2005
    #6
  7. Pioneer <> wrote:

    > Thanks for the reply



    What reply?

    Please quote some context in followups like everybody else does.

    [ I think the reply was one referring you to the Perl FAQ ]


    > but i dont have perldoc installed on our server.


    That is not an excuse for posting to the Perl newsgroup without
    first checking the Perl FAQ.

    You must check the Perl FAQ somehow, it is easier if you have
    a properly installed perl, but it appears you will have to find
    the Perl FAQ some other way.

    Have you tried googling for it?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Aug 17, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QWJlbCBDaGFu?=
    Replies:
    6
    Views:
    9,328
    Rahul
    May 3, 2006
  2. =?Utf-8?B?SmF2?=

    Is ViwState Page-Specific or UserControl-Specific

    =?Utf-8?B?SmF2?=, Aug 16, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    530
    =?Utf-8?B?SmF2?=
    Aug 16, 2006
  3. mazdotnet
    Replies:
    2
    Views:
    396
    Alexey Smirnov
    Oct 2, 2009
  4. 2291980
    Replies:
    2
    Views:
    80
    pcx99
    Feb 19, 2007
  5. William FERRERES
    Replies:
    7
    Views:
    216
    William FERRERES
    Jul 9, 2007
Loading...

Share This Page