2

In this case the character is "^".

For example in the following format with 3 columns.

From:

1 cccc cccc 2 cta^<t cta^<tcc 3 ccc cccc^* 4 ^]a^*c^*c ^]a^*c^*c 

To:

1 cccc cccc 2 ctat ctatcc 3 ccc cccc 4 acc acc 

I'm quite sure this is possible with sed.

3 Answers 3

3

To match your demonstration input/output, it should just be s/\^.//g. To match the description, you need s/\^./\^/g (i.e., you've described it as removing the following character, but shown removing both the caret and the following character).

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, this works perfectly. And yes I slightly misprashed my question.
The ^ does not need to be escaped in the replacement: s/\^./^/g is fine.
2

Do you mean sed 's/\^.//g' ? This removes ^ and the following character.

Comments

0

Here is an awk solution (just offered as another Unix tool alternative, you already have sed solutions)

awk '/^/{gsub(/\^./,"", $0)};1' data.txt 

gives

1 cccc cccc 2 ctat ctatcc 3 ccc cccc 4 acc acc 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.