I have text file that have multi lines I want to search for lines containing some text and add # at the start of those lines.
ex: file1 that I want to change it
acnet 6801/tcp # ACNET Control System Protocol acnet 6801/udp # ACNET Control System Protocol dlip 7201/tcp # DLIP dlip 7201/udp # DLIP ssp-client 7801/tcp # Secure Server Protocol - client ssp-client 7801/udp # Secure Server Protocol - client I want to find ports located in inputfile1. input file one contains:
6801 7801 so the final output of file1 will be like this:
#acnet 6801/tcp # ACNET Control System Protocol #acnet 6801/udp # ACNET Control System Protocol dlip 7201/tcp # DLIP dlip 7201/udp # DLIP #ssp-client 7801/tcp # Secure Server Protocol - client #ssp-client 7801/udp # Secure Server Protocol - client I tried
cat /etc/services |grep -f ports.txt | awk '{ print"#" $g}'; but this give me the output to screen. How to change them in the file?