How to replace the 4th occurrence of a character in a file using sed

sed -i "s/\"/ \"/4" myFile.txt

The above command will replace the 4th occurrence of by in file “myFile.txt”, which is equivalent to putting a space in front of the 4th double quote.

About albertsk

Professor at the University of Hawaii
This entry was posted in Uncategorized and tagged . Bookmark the permalink.