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)'
Share to Twitter
Share to Facebook
Share to Pinterest
Post a Comment
Post Comments (Atom)