Delete only first occurrence of character using tr

g4ur4v

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
Joseph R.

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

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Java, Replace only the first occurrence of a Sharp Character (#)

From Dev

Delete till first occurrence of colon using sed

From Dev

Delete till first occurrence of pipe "|" using sed

From Dev

How can I get sed to only match to the first occurrence of a character?

From Dev

Split on first occurrence of character

From Dev

Using Regex to catch text until first occurrence of certain character

From Dev

Replace only first occurrence

From Dev

awk split on first occurrence of character

From Dev

awk split on first occurrence of character

From Dev

How to remove only the first occurrence of a line in a file using sed

From Dev

Want to replace a string only at first occurrence using sed

From Dev

how to insert file contents on match using sed - first occurrence only

From Dev

Delete dot from all new lines only if its first character

From Dev

Match only first occurrence of digit

From Dev

awk - split only by first occurrence

From Dev

Match only the first occurrence of a phrase

From Dev

QString replace only first occurrence

From Dev

Php token on first occurrence only

From Dev

Match only the first occurrence of a phrase

From Dev

Regex matching first occurrence only?

From Dev

replace only first occurrence of a word

From Dev

Delete text before the specific occurrence of a character in Python

From Java

Split string based on the first occurrence of the character

From Dev

PowerShell Split a String On First Occurrence of Substring/Character

From Dev

Cut string after first occurrence of a character

From Dev

JavaScript RegEx - replace first and last occurrence of a character

From Dev

Regex get all before first occurrence of character

From Dev

regex match first occurrence of a single character

From Dev

Replace all occurrence of character except first one

Related Related

  1. 1

    Java, Replace only the first occurrence of a Sharp Character (#)

  2. 2

    Delete till first occurrence of colon using sed

  3. 3

    Delete till first occurrence of pipe "|" using sed

  4. 4

    How can I get sed to only match to the first occurrence of a character?

  5. 5

    Split on first occurrence of character

  6. 6

    Using Regex to catch text until first occurrence of certain character

  7. 7

    Replace only first occurrence

  8. 8

    awk split on first occurrence of character

  9. 9

    awk split on first occurrence of character

  10. 10

    How to remove only the first occurrence of a line in a file using sed

  11. 11

    Want to replace a string only at first occurrence using sed

  12. 12

    how to insert file contents on match using sed - first occurrence only

  13. 13

    Delete dot from all new lines only if its first character

  14. 14

    Match only first occurrence of digit

  15. 15

    awk - split only by first occurrence

  16. 16

    Match only the first occurrence of a phrase

  17. 17

    QString replace only first occurrence

  18. 18

    Php token on first occurrence only

  19. 19

    Match only the first occurrence of a phrase

  20. 20

    Regex matching first occurrence only?

  21. 21

    replace only first occurrence of a word

  22. 22

    Delete text before the specific occurrence of a character in Python

  23. 23

    Split string based on the first occurrence of the character

  24. 24

    PowerShell Split a String On First Occurrence of Substring/Character

  25. 25

    Cut string after first occurrence of a character

  26. 26

    JavaScript RegEx - replace first and last occurrence of a character

  27. 27

    Regex get all before first occurrence of character

  28. 28

    regex match first occurrence of a single character

  29. 29

    Replace all occurrence of character except first one

HotTag

Archive