Find the answer to your Linux question:
Results 1 to 3 of 3
Hello, I've a bash shell script, which generates a file with the following content: compute-0-0 compute-0-0 compute-0-1 compute-0-0 compute-0-0 compute-0-0 ... I need to modify this file with the same ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    13

    How to: Replace "compute-0-" with "ibc" in a file

    Hello,

    I've a bash shell script, which generates a file with the following content:

    compute-0-0
    compute-0-0
    compute-0-1
    compute-0-0
    compute-0-0
    compute-0-0
    ...

    I need to modify this file with the same script such that it should replace the first 10 characters, i.e. "compute-0-" with "ibc".

    How to do this?

    With what all commands can this be achieved?

    Thanks,
    Sangamesh

  2. #2
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    Code:
    sed -i 's/^compute-0-/ibc/' file

  3. #3
    Just Joined!
    Join Date
    Oct 2007
    Posts
    13
    Thanks. Its working

Posting Permissions

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