I have 3000 words that are repeated (ARG ARG ARG ARG ....)
I am trying to search and replace the 500th word by 'UIO'
I have been trying it with sed -i 's/ARG/UIO/500' filename.txt
I have also tried it with sed -i 's/ARG/UIO/500g' filename.txt but it does not work.
I does not report any mistake but it doesn't change anything in filename.txt either.
What would you recommend me to do?
ARGandsed 's/ARG/UIO/500'worked exactly as expected. So something is different in your case. Please post an example of your input file that reproduces the problem.-zoption to make it do it on the 500th occurrence in the file as opposed to the 500th occurrence of each line (assuming the file doesn't contain NUL characters and a recent enough version of GNUsed).