I have a txt (ip.txt) file that contains IP addresess. I group them under TCP and UDP. File excerpt is below:
#TCP 162.298.38.930 162.298.38.931 162.298.38.932 #UDP 162.298.38.930 162.298.38.931 162.298.38.932 I have a specific IP (162.298.38.929) to add both by bash script into this ip.txt under TCP and UDP lines so it should like this.
#TCP 162.298.38.929 162.298.38.930 162.298.38.931 162.298.38.932 #UDP 162.298.38.929 162.298.38.930 162.298.38.931 162.298.38.932 How can I achieve this in bash script? Line number is not usable for my case because #TCP and #UDP line number can change because I add lots of comments into the file. Bash Script should search and add the IP both under TCP and UDP.