Q: output content in second occurrence I have a log file that is producing output as:
[+] [1.1.1.1] LOG HERE

I would like to know how I can extract the IP from the log to send to a "clean" file, that only list the IP.

A: With awk, tested on GNU Awk 4.1.3, not sure if it won't work with other versions
$ cat ip.txt 
[+] [1.1.1.1] LOG HERE

$ awk -F'[][]' '{print $4}' ip.txt 
1.1.1.1



*

*-F'[][]' set input field separator as [ or ]

*{print $4} print the 4th field



With sed, assuming input file has consistent pattern like shown in sample
$ sed 's/.*\[//; s/].*//' ip.txt 
1.1.1.1



*

*s/.*\[// delete from start of line up to last [ in the line

*s/].*// from the so modified line, delete everything from first ] to end of line

