I have a file, file1.txt
, like this:
This is some text.
This is some more text. ② This is a note.
This is yet some more text.
I need to delete any text appearing after "②", including the "②" and any single space appearing immediately before, if such a space is present. E.g., the above file would become file2.txt
:
This is some text.
This is some more text.
This is yet some more text.
How can I delete the "②", anything coming after, and any preceding single space?
- The solutions at How can I remove all text after a character in bash? do not seem to work, perhaps because "②" is not an ordinary character.
- The file is saved in UTF-8.