I'm looking for a way to join lines in a file; e.,g consider the following
R|This is line 1
R|This is
line 2
R|This is line 3
R|This is line 4
R|This is
line 5
what i want to end up with is
R|This is line 1
R|This is line 2
R|This is line 3
R|This is line 4
R|This is line 5
so the 'real' lines start with R but there may be a line break in some of the lines therefore wanna get rid of the line break if the next line doesn't start with R|
make sense??
thanks in advance
PS been trying with sed and awk... but it's not very intuitive
thanks, but that still leaves me the problem of spaces; so
R|This is
Line1
changes to
R|This isLine1
but I want
R|This is Line1
any ideas??
I guyss I could use sed to do a substitution to put a space infront of every line that doesnt begin with R, that will solve it... but can anyone think of a neater way?
# cat file
R|This is line 1$
R|This is $
line 2$
R|This is line 3$
R|This is line 4$
R|This is $
line 5$
R|This is $
line 6$
R|This is$
line 7$
# awk '{if(!/^ *line/){x=$0;s1=gensub("(.*is).*","\\1",x);s=gensub("is(.*)","\\1",x);if(s~/ +/)s=" ";if(/line/)print x}\
else{xx=xx?xxFS$0:$0;print s1 s xx}}' file
R|This is line 1
R|This is line 2
R|This is line 3
R|This is line 4
R|This is line 5
R|This is line 6
R|This is line 7
Please don't give just an example data. This is a form to help people who really seeking for help. And if, you are looking for any answer please give exact data to help you out. Thanks.
After having some issues around spaces and format I decided to try a basic approach, so I wrote an easy to read script. It may not be the most optimal but it does the job and is easy to maintain.
So, the code joins lines into one (so that they all start with R| ). Then performs some sentiment analysis on the line and appens |positive |negative or |neutral at the end