I have a csv file with some (dirty) DB schema.
example:
10391,0,3,4,12,44 --ok
10391,0,3,4, --not ok
12,44 --not ok
10391,0,3,4,12,44 --ok
I want to write sed script to replace new line characters (not followed by 5-digit number) with spaces.
Wrote this one, but not works correctly for me:
sed 's/\n\([0-9]{1,4}\)/ \1/g'
running on this sample
11111 sss
22222 aaa
3333 aaa
333 sss
22 sss
1 sss
should produce
11111 sss
22222 aaa 3333 aaa 333 sss 22 sss 1 sss
thanks to anyone who will be able to help
perl -0777 -pe 's/\n(?!\d{5}\b)/ /g' yourfile
Explanation
\n
matches the newline(?!\d{5}\b)
asserts that what follows is not five digits and a word boundaryCollected from the Internet
Please contact [email protected] to delete if infringement.
Comments