I have a file with 10000 lines like this:
Peptidyl-prolyl cis-trans isomerase A OS=Homo sapiens GN=PPIA PE=1 SV=2 - [PPIA] 0.8622399654 3.2730004556
I cant figure out how to remove part of the string up to square bracket, so that final output looks like this:
[PPIA] 0.8622399654 3.2730004556
So far I tried python re.sub, but can't match it to the beginning of the line.
With sed it's a simple substitution:
sed 's/^[^[]*\[/[/' input
^
means start of pattern space ("line"), and [^[]
matches everything but [
. *
is a quantifier which means zero or more times. \[
is a literal [
.
With sed:
sed 's/^[^[]*//' file
Disadvantage: If a line doesn't contain [
, sed outputs an empty line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With