0

I need to remove all numbers before "|" symbol. I tried some suggestions on a previous question (Delete everything before "/" on every line) but did not work for me. For example:

113|gm1.1_g
115|gm1.3_g
350400|fgenesh1_kg.28251_#_1_#_remain_c2214

Then I would like to have:

gm1.1_g
gm1.3_g
fgenesh1_kg.28251_#_1_#_remain_c2214

Thanks

1
  • From the linked question, which methods did you try and in what way, precisely, did they not work for you?
    – John1024
    Feb 8 '18 at 23:42
1

The regex that mean "all numbers before |" (at the line start) is:

^[0-9]*|

Use that with sed:

$ echo "113|gm1.1_g" | sed 's/^[0-9]*|//'
gm1.1_g

Awk:

$ echo "113|gm1.1_g" | awk 'sub(/^[0-9]*\|/,"")'
gm1.1_g

shell:

$ a="113|gm1.1_g"; r='^[0-9]*\|(.*)$'; [[ $a =~ $r ]]; echo "${BASH_REMATCH[1]}"
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.