Post History
What is the simplest shell idiom for stripping leading and trailing whitespace from a file or program output? Ideally I am looking for the equivalent of trim or strip methods in some languages. Th...
Question
text-processing
#4: Post edited
Simplest way of stripping leading/trailing whitespace from standard input
- Simplest way of stripping leading/trailing whitespace from file or program output
What is the simplest shell idiom for stripping leading and trailing whitespace from standard output? Ideally I am looking for the equivalent of `trim` or `strip` methods in some languages.There is potentially a confusion here about whether I'm asking about trimming only the first and last lines, or if every line should individually be trimmed. An ideal solution would assume the first, but make the second a CLI switch.
- What is the simplest shell idiom for stripping leading and trailing whitespace from a file or program output? Ideally I am looking for the equivalent of `trim` or `strip` methods in some languages.
- The ideal solution should
- * skip empty lines at the beginning and end of the file/stream
- * provide an option to also strip leading and trailing whitespace from all non-empty lines
#3: Post edited
Simplest way of stripping leading/trailing newlines from standard input
- Simplest way of stripping leading/trailing whitespace from standard input
- What is the simplest shell idiom for stripping leading and trailing whitespace from standard output? Ideally I am looking for the equivalent of `trim` or `strip` methods in some languages.
There is potentially a confusion here about whether I'm asking about trimming only the first and last lines, or if every line should individually be trimmed. An idea solution would assume the first, but make the second a CLI switch.
- What is the simplest shell idiom for stripping leading and trailing whitespace from standard output? Ideally I am looking for the equivalent of `trim` or `strip` methods in some languages.
- There is potentially a confusion here about whether I'm asking about trimming only the first and last lines, or if every line should individually be trimmed. An ideal solution would assume the first, but make the second a CLI switch.
#2: Post edited
Simplest way of stripping leading/trailing newlines from STDOUT
- Simplest way of stripping leading/trailing newlines from standard input
#1: Initial revision
Simplest way of stripping leading/trailing newlines from STDOUT
What is the simplest shell idiom for stripping leading and trailing whitespace from standard output? Ideally I am looking for the equivalent of `trim` or `strip` methods in some languages. There is potentially a confusion here about whether I'm asking about trimming only the first and last lines, or if every line should individually be trimmed. An idea solution would assume the first, but make the second a CLI switch.