#!/bin/bash s='Hello there! How are you? I am trying to figure this out.' sed 's/\(.\{10\}[^[:space:]]*\)[[:space:]]\{1,\}/\1|/g' <<< "$s" sed -E 's/(.{10}[^[:space:]]*)[[:space:]]+/\1|/g' <<< "$s"
Standard input is empty
Hello there!|How are you?|I am trying|to figure this|out. Hello there!|How are you?|I am trying|to figure this|out.