If you can slurp whole input:
perl -e'undef$/;
$a=<>;
print "$_\n" for $a=~m/(?:\b\S+\b\s+){5}your regexp(?:\s+\b\S+\b){5}/sg
' <input
— 5 words of context.
More Related Contents:
- Convert 11/2/1998 to 110298 [duplicate]
- Iterating through a CSV and pulling out the last line of the day for each element
- How can I manipulate text in bash? [closed]
- Fastest way to find lines of a file from another larger file in Bash
- What are the differences between Perl, Python, AWK and sed? [closed]
- Extracting data from HTML table
- Get java version number from python
- What is Perl's equivalent of Python's time.time()? [closed]
- Awk – replace coumn 2 in table 1 from coumn 2 in table 2 based on matching data in column 1 (common between tables)
- Running Bash commands in Python
- How to merge every two lines into one from the command line?
- How to set env variable in Jupyter notebook
- running multiple bash commands with subprocess
- Python output to Console within Subprocess from the child scricpt
- Python subprocess .check_call vs .check_output
- Conda command working in command prompt but not in bash script
- How to store the result of an executed shell command in a variable in python? [duplicate]
- Interacting with bash from python
- Run BASH built-in commands in Python?
- Grep and Python
- PYTHONPATH not working for sudo on GNU/Linux (works for root)
- Launch a python script from another script, with parameters in subprocess argument
- Bash style process substitution with Python’s Popen
- How to pass a Bash variable to Python?
- store return value of a Python script in a bash script
- Regexp finding longest common prefix of two strings
- Calling a Python function from a shell script
- creating an alias for python3
- run python script directly from command line
- How to match a substring in a string, ignoring case