How to delete everything in a string after a specific character?

后端 未结 3 342
面向向阳花
面向向阳花 2021-02-04 07:15

Example:

    before: text_before_specific_character(specific_character)text_to_be_deleted
    after: text_before_specific_character

I know that

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 07:39

    What you're looking for is actually really easy:

    sed 's/A.*//'
    

    Where A marks the specific character. Note that it is case sensitive, if you want to catch multiple characters use

    sed 's/[aAbB].*//'
    

提交回复
热议问题