Awk, sed - concatenate lines starting with string

I have a file that looks like this:

John Smith
http://www.profile1.com
http://www.profile2.com
http://www.profile3.com
Marc Olsen
http://www.profile4.com
http://www.profile5.com
http://www.profile6.com
http://www.profile7.com
Lynne Doe
http://www.profile8.com
http://www.profile9.com

I need to add every line that starts with "http://" to last line that doesn't start with "http://", so that the file becomes:

John Smith;http://www.profile1.com;http://www.profile2.com;http://www.profile3.com
Marc Olsen;http://www.profile4.com;http://www.profile5.com;http://www.profile6.com;http://www.profile7.com
Lynne Doe;http://www.profile8.com;http://www.profile9.com

The following seems to do what you want:

awk '! /^http/ {
        if(nnl) printf("\n")
        nnl = 1
        printf("%s", $0)
        next
}
{       printf(";%s", $0)
}
END {   if(nnl) printf("\n")
}' input

Note that this will work with both http: and https: sites, but won't do the right thing if someone's name starts with http.

awk 'NR==1&&!/^http/{n=$0}NR!=1&&!/^http/{print n,p; n=$0; p="";}/^http/{p=p";"$0;}END{print n,p;}' file

This works with both http- and https-URLS and won't be confused by names starting with "http". @Don: good idea with the https, making the "s" optional would work in awk too.

sed '/^https*:/ !{ H ; s/.*// ; x ; p }
     /^https*:/ { s/^/;/ ; H }' /path/to/infile

I hope this helps.

bakunin