Replace a line with a number if part of it is matches using sed

I know this is a very simple question and discussed many times, but I can’t understand where I am doing mistake in my command.

I would like to replace the lines which starts with “It” as 99999. Each row starts with several blank spaces.

infile.txt
     3
     2
     3
     4
  It is not a number = /home/kayan/data
     3
     5
  It is not a number = /home/kayan/data
     4
     5

I used

sed -i 's/^I/99999/g' infile.txt

But it not working.


Source: shell

Leave a Reply