I have a input.txt file with over 6000 lines.
If a line a has over 10 words then I want it to be split but not at the 10th word but where the first comma character appe
OK, so here is how I solved this problem. It's ugly, but it works. Plus I can keep piping more sed commands to add more conditions (like my comment above @ghoti).
sed -r '/((\w)+[., ]+){10}/s/\./\.\n/' input.txt | sed -r '/((\w)+[., ]+){10}/s/\./\.\n/' | sed -r '/((\w)+[., ]+){10}/s/\./\.\n/' | sed -r '/((\w)+[., ]+){10}/s/\./\.\n/'| sed -r '/((\w)+[., ]+){10}/s/\./\.\n/' | sed -r '/((\w)+[., ]+){10}/s/\./\.\n/' | sed -r '/((\w)+[., ]+){10}/s/\./\.\n/' | tr -s [:space:] > output.txt
Basically, I just piped the same sed command 7 times (in the above sample I'm replacing periods instead of commas, but all the same). Based on what I read on-line, I'm surprised this command does not allow some of recursive/reiteration. Or if someone knows, please feel free to edit.