How do i place a string after a number of spaces using sed?
-
Man page for sed: https://www.lightnetics.com/post/3334
The sample copy of the file:
This is my first IP 10.50.20.1 grapes apples pears This is the first block oranges PLUMS This is my second IP 10.50.20.2 This is my duplicate IP 10.50.20.2 grapes apples pears This is the second block oranges PLUMS This is my third IP 10.50.20.3 grapes apples pears This is the third block oranges plums
Here's we adding a string after the third space. The word "great" is placed after the third space.
$ cat samplefile | sed 's/ /&great /3'
© Lightnetics 2024