Pal's Web Log
Programming - Linux, Ubuntu, Python, Django, Postgres, HTML, Cloud, Data Science etc.
Labels
Django
Docker
Google Cloud
Linux
Postgres
Python
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)'
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)