I have a file names 'log.txt' that looks something like this:
#This is a comment
/sbin/iptables -A INPUT -p tcp -s ip.of.a machine --destination-port 21 -j ACCEPT
#This is the comment to read#
/sbin/iptables -A INPUT -p tcp -s ip.of.a.machine --destination-port 21 -j ACCEPT
I would like to use sed to search for the line ending in 'read#', read in the next line, then do a replace, and write it to a new file.
So, just to experiment, I searched for #read, a new line, then /sbin/iptables/ and replaced it with /sbin/replace.
sed 'N;s/read#\n\/sbin\/iptables/\/sbin\/replace/' log.txt > log1.txt
This didn't change anything. Does it have to do with the \n and reading the next line? Please advise. Thanks