I have a script that generates following output:URL: http://framework.comName(s): Patching Framework----------------------------------------------------------URL: http://asjkdfhn.comName(s): jadsbfkjdfhn dsjfkh----------------------------------------------------------URL: http://wusdh.comName(s): Wholesale Underwear dark health----------------------------------------------------------URL: http://wertyuiioofn.comName(s): werthyeshfd asjfdhn ajdsfbndjfb dsjfhndjfhn dkfmdkfm dkfjkdjf----------------------------------------------------------URL: http://google.comName(s): Google Google, Phillipines----------------------------------------------------------I want to print/echo only those URLs/Name(s) which have more than one names listed.Example: From above URLs/Name(s), only following to be printed: URL: http://wertyuiioofn.comName(s): werthyeshfd asjfdhn ajdsfbndjfb dsjfhndjfhn dkfmdkfm dkfjkdjf----------------------------------------------------------URL: http://google.comName(s): Google Google, Phillipines----------------------------------------------------------Is it possible to do using bash/shell scripting?
How to search whether more than one lines exist after a certain string?
bash;shell script
This should work. Add your filename after this command:sed -n '       /URL:/{              :addanotherrow              N              /-\{50,\}/bmatchandprint              baddanotherrow              :matchandprint              /Name(s):[^\n]*\n[^-\n]*\n[^-]/p              }       'Some explanations:the sed parameter -n prevents automatic printing of pattern space - the matched patterns are printed with the p at the end of the last row of the  statements inside the brackets {}labels are marked with a leading :, so :addanotherrow and :matchandprint are jumping points for the b statementsb followed by a label is a command to branch to that label (something like a GOTO)N appends the next line of input into the pattern spacelines starting with / just proof the pattern space against a regular expression, when the regex fits, the following command is executed,  as already mentioned the b branches and the p prints the pattern spaceIn other words: the string URL: is searched, from that point more rows are included until a line (at least 50 hyphens in a row) was found. After that the gathered rows (pattern space) are examined. Only when a Name(s): with more than one row (that is not beginning with a hyphen) was found, the pattern space will be printed.Hope that helps :-)