Philipp Meissner
Philipp Meissner

Reputation: 5482

Remove specific partial string including special characters from string

Imagine I have a string like:

* This could be any text really - maybe even with strange characters --skip-ci

From this string using sed in my bash I want to remove the possibly occuring --skip-ci part. I managed to come across a regexp using word boundary to remove the skip-ci part.

It looks like: \bskip-ci\b

Unfortunately this isn't working in my bash and it will not remove the -- as well (Using it like: sed '\bskip-ci\b').

If you can give me a hint what to look for, that'd be highly appreciated!

Upvotes: 1

Views: 56

Answers (1)

Thomas Ayoub
Thomas Ayoub

Reputation: 29471

You can use:

sed s/'--skip-ci'/''/g test.txt

output:

2016-11-02 16:45:29 ☆  DESKTOP in ~
  ○ → more test.txt
* This could be any text really - maybe even with strange characters --skip-ci

2016-11-02 16:45:58 ☆  DESKTOP in ~
  ○ → sed s/'--skip-ci'/''/g test.txt
* This could be any text really - maybe even with strange characters

Upvotes: 1

Related Questions