I have a file of the following format (delimited by |)
this is field 1 | field 2 (lots of blank spaces) | field 3 (lots of blank space) |
field 1 | more text (lots of blank spaces) | dhjdsk |
Is there a way I can remove trailing spaces between the end of the text in each field and the delimiter? E.g. I would like to end up with the following...
this is field 1 | field 2 | field 3 |
field 1 | more text | dhjdsk |
Using the line of code above, i get trailing spaces to be removed between the end of the field and the delimiter. I was hoping someone might explain how the command knows to take from the last space.
For example, if i have a field a row in $FILE such as...
this is field 1 | this is field 2 | a lot of text in field 3
...how does the command know to remove the space after the "1" instead of taking everything after the first space, i.e., after "this".