Programming - Linux, Python, Android, Databases, HTML etc.
Thursday, July 23, 2015
Grep between two words in string
Say from the string "Age: = 24 years",
you want to extract the value 24. Grep can be used to search for a pattern between two words. Here is the grep command for that:
echo "Age: = 24 years" | grep -P -o '(?<=Age: = ).*(?= years)'
Links to this post
Share to Twitter
Share to Facebook
Share to Pinterest