I have a huge text file with something like that:igflex01; igflexdev01; igdbstg01;igldapint01; igjetdev01; igsql01;igesxstg01; igdbint01; igdmstg01;igdsdev01; igdmmmo01; igmsgint02;and so on...I would like to extract all text between semicolons when the string 'int' is present.Is there a way to do that?
sed / awk / grep find string between semicolons
linux;sed;awk;grep
Since you asked for sed / grep, here it is:> cat fileigflex01; igflexdev01; igdbstg01;igldapint01; igjetdev01; igsql01;igesxstg01; igdbint01; igdmstg01;igdsdev01; igdmmmo01; igmsgint02;> sed -nr 's/\s*;\s*/\n/gp' file | grep intigldapint01igdbint01igmsgint02Or get it with only a single sed call...> sed -nr -e 's/\s*;\s*/\n/g;/int/P' fileigldapint01igdbint01igmsgint02