Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 3
    I imagine an awk-based answer would be more straight-forward; would that be acceptable? Commented Jun 3, 2020 at 19:17
  • Everything here is great. I've gone with the one that entirely uses a single sed pipeline (see its comment to know why.) If any readers want that too, scroll down cos it's not very upvoted atm. Commented Jun 4, 2020 at 16:18
  • (1) Please specify what should be done with CAT, (i.e., CAT followed by punctuation), CATCH, BOBCAT and LOCATE. (2) steeldriver's answer IS a single sed command — see the comments.  Even Dale Hagglund agrees. Commented Jun 5, 2020 at 0:42
  • Thank you G-Man for also pointing that out, I really messed up quite a lot there so I'll edit what I can. Re adjacent characters to CAT, my simplified question is ambiguous. I'm not sure which solutions here have assumed spaces or have not. I'll edit the question to say this. In the actual use case (complex bash function about tags in filenames) CAT is illegal if bordered by any alphanumeric characters and will have been filtered out earlier on. Commented Jun 5, 2020 at 15:49