Search This Blog

Use grep to extract substring between two specific characters/words

Input:
00024D9E: (0051,100F) LO 4 [A11]


Output:
A11

To achieve the above,
echo "00024D9E: (0051,100F) LO 4 [A11]" | grep -o -P '(?<=\[).*(?=\])'

No comments:

Post a Comment