0

What command would you give to print (display on the screen) the corrected text of userNotes.txt with all sentence endings having required two blanks before the start of the next sentence?

This is the question I'm trying to answer using sed, but every attempt I try is wrong. It's possible I'm missing something, but the code I feel should work is:

sed 's/\. /\.  /g' userNotes.txt

It works but not I suppose in this context. The error response gives me:

No. That's not it.
For example, your command listed
    All sessions have those characteristic three steps.   If you are working on a PC where you are the only registered user, you might log in
where I was expecting
    All sessions have those characteristic three steps.  If you are working on a PC where you are the only registered user, you might log in

which has my two spaces as being too large. It's supposed to be a simple answer, but I don't believe it gets simpler than this. I also cannot use things like [[:space:]], awk, etc. just basic sed edit.

marked as duplicate by JigglyNaga, Jeff Schaller, user88036, Romeo Ninov, Toby Speight Oct 12 '18 at 14:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Try sed 's/\. */. /g' (notice that there are two spaces in both pattern and replacement). Depending on the text sample, it may be more complex that that -- period and spurious spaces at end-of-line, no space whatsoever after '.' (eg. "... three steps.If you ..."), periods used for other purposes (eg 'v1.2.3'), etc. – mosvy Oct 12 '18 at 3:49
0

You have to use \+ (one or more times). And also I'd use \s, which means every white character.

sed 's/\.\s\+/\.  /g' userNotes.txt
  • Thank you, that wasn't explained very well in my notes and other answers on here were either not in the format I needed or they were never "solved". This worked perfectly. – Sammy Oct 12 '18 at 19:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.