Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all, I'm having a file called Text.txt [code] This is a Test Text File. [code] How can i use sed to replace the word 'File' with 'file' I tried ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,757

    Smile sed Help


    Hi all,
    I'm having a file called Text.txt
    [code]
    This is a Test Text File.
    [code]

    How can i use sed to replace the word 'File' with 'file'

    I tried this
    Code:
    sed -e 's/T/t/g' Txt.txt > Txt.txt
    The file Txt.txt is empty now

    I don't want to redirect result into a tempory file --just want to update the original file.


    Any ideas ???
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  2. #2
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    848
    Try:

    Code:
    sed -i 's/File/file/g' Txt.txt
    Linux User #453176

  3. #3
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,757

    Lightbulb

    Code:
    sed -e 's/T/t/g' Txt.txt > Txt.txt
    :drown: ...Sorry i actually tried this

    Code:
    sed -e 's/File/file/g' Txt.txt > Txt.txt
    earlier...

    Thanks Kieren It works with sed -i option.
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •