leave a new line only before a pattern

i need to reformat a file in shell, so i only leave the 'new line' before some pattern. Ex:

Input:

Europe First
Asia Second
Africa Third
Australia Fourth
Europe Sixth
Australia Seventh
Europe  Eight
America Last

Output:

Europe FirstAsia SecondAfrica ThirdAustralia Fourth
Europe SixthAustralia Seventh
Europe  EightAmerica Last

where the pattern is "Europe"

Answers


perl -i -0777pe's/\n(?!Europe|\z)/ /g' file

Need Your Help

Cannot view my new MVC 4 application

visual-studio-2010 asp.net-mvc-4

I just created a new basic MVC 4 application in VS 2010. I just clicked the play button to test it came up in the web browser and I'm getting the following page:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.