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
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