Hi,
I am trying to remove all instances of the special backspace or delete chars in a log file field. The backspace shows up as ^H in the field.
Currently I use gsub(/["^H"]/, "" to remove the ^H but ideally I also want to delete the previous char. i.e. someone enters gg^H^Hhello (hello). I want to delete the first two chars also. Can someone let me know how I can do this? I imagine a for loop with if statement to check each char in the field.
I would rather not step through each char in this field on every line of the log file as it would take forever. If it's possible to remove the previous char upon detection of the backspace, that would be perfect.
Secondly, I use the statement
END { print NR, "sessions read." }
to display the total no of lines read from the log file. Since I am deleting certain lines, how do I keep a track of the modified no. of lines?? Again some king of for loop??
Hope you can help!!
snowman
I am trying to remove all instances of the special backspace or delete chars in a log file field. The backspace shows up as ^H in the field.
Currently I use gsub(/["^H"]/, "" to remove the ^H but ideally I also want to delete the previous char. i.e. someone enters gg^H^Hhello (hello). I want to delete the first two chars also. Can someone let me know how I can do this? I imagine a for loop with if statement to check each char in the field.
I would rather not step through each char in this field on every line of the log file as it would take forever. If it's possible to remove the previous char upon detection of the backspace, that would be perfect.
Secondly, I use the statement
END { print NR, "sessions read." }
to display the total no of lines read from the log file. Since I am deleting certain lines, how do I keep a track of the modified no. of lines?? Again some king of for loop??
Hope you can help!!
snowman