I was wondering if there was a way to make awk output the number of changes that it has made, or somehow keep track of what it changes. For instance if there was a .csv file, in which I used awk to replace the word “the” with “it”, would there be a way to make awk output how many times it had found and replaced “the” inside of the .csv file? I’ve been searching around on google + the rest of this site but have not been able to find anything, not sure if I am just working it the wrong way or something of the sort though, if someone could help me out with this though I would really appreciate it, thanks!
Share
as far as I know, awk cannot give that substitution counts automatically. We have to sum the number manually somehow. for example, with your “the”->”it”: