I am parsing a sql script using unix. If FROM
is a first word then merge it with previous line. If FROM
is last word in line then we need to merge it with next line. E.g.:
A
FROM
B
I want the result as
A FROM B
avoid any space and tabs.
Code:
cat A.txt | sed ':a;N;$!ba;s|[Ff][Rr][Oo][Mm][\s\t]*\n|FROM |g;s/\n\s*\t*[Ff][Rr][Oo][Mm]/ FROM/g' >B.txt