How do i use pattern matching to exclude certain characters in sed?
-
Man page for sed: https://www.lightnetics.com/post/3334
Sample file used:
cat linefile This is line one 1000 This is line two 2000 This is line three
We want to keep characters This, that's T or t, h, i, and s, we put a
^
symbol in front in the square brackets.$ sed 's/[^This]/ /g' linefile
Result: Including keeping blanks and spaces, goodness know why anyone would want a file like that, but this is just to show the usage.
This is i
This is i
This is i h
© Lightnetics 2024