6

I want to delete the occurrence of a character in a string only for the first occurrence.

Example:

echo "B123_BACK" | tr -d 'B'

This results in output:

123_ACK

How can I delete only the first occurrence of charcater 'B' so that the output looks like

123_BACK

1 Answer 1

14

Looking at the tr man page, this isn't possible. Why not use sed instead:

echo "B123_BACK"|sed 's/B//'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .