Modifying file to 75 characters

I have a text file containing some notes and I want to limit the lines to 75 characters.
Tried using fold, however fold will cut words.

Need something in bash, sed or awk to do this. Find the blank space less than 75 ant cut from there

Have you tried the -s option to fold?

       -s
            Breaks the line after the rightmost blank within the Width limit, if an output line segment contains any blank
            characters. The default is to break lines so each output line segment is as wide as possible.

What have you tried so far? Answers before that from the OP will be moderated.

I tried the

cat test.tex | fold -s -w 75

It does the right thing, however I noticed that it messes the paragraphs up.

This 75 characters are including/excluding white spaces

@kristunu
Please post representative sample input and matching ideal output.

Consider the following text file

\subsection{Providing Useful Feedback}

When providing feedback, treat each other graciously and kindheartedly. That does not mean
that we do not criticize one another; we do, but we give constructive criticism.

There are three rules to follow:

\begin{itemize}

\item \textbf{Rule 1} Surround constructive criticism with encouragement. First point out at
least one strength of the interactive note, focus statement, or outline, and then present our
question or constructive criticism.

\item \textbf{Rule 2} Be more explicit and precise while framing questions - the more precise,
the less likely that the questions will be misunderstood. Rather than \char`\"{}\emph{What
did you mean by that?}\char`\"{} (which can interpreted as genuinely inquisitive or highly
dismissive), use questions such as: \char`\"{}\emph{I'm intrigued by your theory. What did
you mean by using it in that context?}\char`\"{} or \char`\"{}\emph{I don't quite understand
what you mean by {[}a specific point{]}. Could you please explain it a little more?}\char`\"{}

\item \textbf{Rule 3} Own your comments so the presenter answers you in a constructive manner.
Do not use comments such as \char`\"{}\emph{That theory doesn't make sense.}\char`\"{} Stick
to \char`\"{}\emph{I don't understand the theory you are presenting}\char`\"{} or \char`\"{}
\emph{I don't understand why you are focusing on that theory.}\char`\"{}

\end{itemize}

Critique and feedback, when appropriate, ought to come out of generosity and compassion, and
with an intention to make the other person look good.
cat test.tex | fold -s -w 75

gives

\subsection{Providing Useful Feedback}

When providing feedback, treat each other graciously and kindheartedly. 
That does not mean
that we do not criticize one another; we do, but we give constructive 
criticism.

There are three rules to follow:

\begin{itemize}

\item \textbf{Rule 1} Surround constructive criticism with encouragement. 
First point out at
least one strength of the interactive note, focus statement, or outline, 
and then present our
question or constructive criticism.

\item \textbf{Rule 2} Be more explicit and precise while framing questions 
- the more precise,
the less likely that the questions will be misunderstood. Rather than 
\char`\"{}\emph{What
did you mean by that?}\char`\"{} (which can interpreted as genuinely 
inquisitive or highly
dismissive), use questions such as: \char`\"{}\emph{I'm intrigued by your 
theory. What did
you mean by using it in that context?}\char`\"{} or \char`\"{}\emph{I 
don't quite understand
what you mean by {[}a specific point{]}. Could you please explain it a 
little more?}\char`\"{}

\item \textbf{Rule 3} Own your comments so the presenter answers you in a 
constructive manner.
Do not use comments such as \char`\"{}\emph{That theory doesn't make 
sense.}\char`\"{} Stick
to \char`\"{}\emph{I don't understand the theory you are 
presenting}\char`\"{} or \char`\"{}
\emph{I don't understand why you are focusing on that theory.}\char`\"{}

\end{itemize}

Critique and feedback, when appropriate, ought to come out of generosity 
and compassion, and
with an intention to make the other person look good.

Yes, but what should the output look like?

Output would look something like this

\subsection{Providing Useful Feedback}

When providing feedback, treat each other graciously and kindheartedly. 
That does not mean that we do not criticize one another; we do, but we
give constructive criticism.

There are three rules to follow:

\begin{itemize}

\item \textbf{Rule 1} Surround constructive criticism with encouragement. 
First point out at least one strength of the interactive note, focus
statement, or outline, and then present our question or constructive
criticism.

\item \textbf{Rule 2} Be more explicit and precise while framing questions 
- the more precise, the less likely that the questions will be
misunderstood. Rather than \char`\"{}\emph{What did you mean by 
that?}\char`\"{} (which can interpreted as genuinely inquisitive or highly
dismissive), use questions such as: \char`\"{}\emph{I'm intrigued by your 
theory. What did you mean by using it in that context?}\char`\"{} or 
\char`\"{}\emph{I don't quite understand what you mean by {[}a specific
 point{]}. Could you please explain it a little more?}\char`\"{}

\item \textbf{Rule 3} Own your comments so the presenter answers you in a 
constructive manner. Do not use comments such as \char`\"{}\emph{That
theory doesn't make sense.}\char`\"{} Stick to \char`\"{}\emph{I don't
understand the theory you are presenting}\char`\"{} or \char`\"{}
\emph{I don't understand why you are focusing on that theory.}\char`\"{}

\end{itemize}

Critique and feedback, when appropriate, ought to come out of generosity 
and compassion, and with an intention to make the other person look good.


fmt

Regards,
Alister

2 Likes

Brilliant, that's what I'm looking for. :b: