I have following string in text file:
^25555555~BIG^20200629^20022222^20200629^55555555^^^DI^00~CUR^ZZ^USD
and want to fetch string between BIG^
and ^00
i.e.
20200629^20022222^20200629^25523652^^^DI
. I tried to use following command but it is not working, may be because of special character caret ^
.
echo "^25555555~BIG^20200629^20022222^20200629^25523652^^^DI^00~CUR^ZZ^USD" | grep -o -P '(?<=BIG^).*(?=^00)'
I tried removing caret from search and it is working but need to include caret in my search:
echo "^25555555~BIG^20200629^20022222^20200629^55555555^^^DI^00~CUR^ZZ^USD" | grep -o -P '(?<=BIG).*(?=00)'
above command returns: ^20200629^20022222^20200629^55555555^^^DI^
How to fetch part of string from string containing special character caret ^ using grep?