Here is my code:
grep -E -o "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b|first_name.{0,40}|[(]?[2-9]{1}[0-9]{2}[)-. ]?[2-9]{1}[0-9]{2}[-. ]?[0-9]{4}" file.txt | awk -v ORS= '
NR>1 && !/,/ {print "\n"}
{print}
END {if (NR) print "\n"}' | sed -e :a -e '$!N;s/\n[0-9]{3}/,/;ta' -e 'P;D' | sed '$!N;s/\n\s*[0-9]//;P;D'
I'm pretty close. The above code works, but is removing the first digit from phone number.
I'm looking for a bash solution to do the following:
Combine two lines if the lines do not start with a number. If the line starts with a number, combine the previous two lines + the line with the number for 3 fields in one line.
Here's an example?
jim.bob3@email.com Jim Bob jane.bob@email.com Jane Bob joebob1122@email.com Joe Bob 555 555 5555 jbob44@email.com Jeff Bob .... Results: jim.bob3@email.com Jim Bob jane.bob@email.com Jane Bob joebob1122@email.com Joe Bob 555 555 5555 jbob44@email.com Jeff Bob
Thanks!