Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

grep return n characters before or after match

# Basic syntax:
grep -o -E '.{0,3}string.{0,4}' your_file.txt
# Where:
#	- This expression returns 3 characters before string and 4 after
#	-o specifies returning only the matching text, not the entire line
#	-E specifies allowing extended regular expressions (some answers
#		change this to -P, but that doesn't work on macOS)
# Note, add the -m flag if you want to specify the number of matches to
#	allow per line (e.g. -m 2)
Comment

PREVIOUS NEXT
Code Example
Shell :: pulseeffects ubuntu 
Shell :: pip install pandas 
Shell :: git origin 
Shell :: CAPACITOR_ANDROID_STUDIO_PATH 
Shell :: adding jars to classpath in linux 
Shell :: update ubuntu not working 
Shell :: npx not found 
Shell :: linux how to show disk space 
Shell :: pip missingno 
Shell :: conda install openjdk=11 
Shell :: git untrack file 
Shell :: check compatible ubuntu nvidia driver 18.04 
Shell :: bash remove empty line 
Shell :: git remove commit 
Shell :: how to stop mongodb in linux 
Shell :: kill process running on port in windows 
Shell :: git fetch all remote branch 
Shell :: install yum terminal 
Shell :: fatal: You are not currently on a branch. To push the history leading to the current (detached HEAD) state now, use git push origin HEAD:<name-of-remote-branch 
Shell :: linux ip forwarding 
Shell :: bash date today plus one day 
Shell :: start ssh agent windows 10 
Shell :: restart webmin 
Shell :: install epel repo centos 7 
Shell :: how download google drive file with wget 
Shell :: w: some index files failed to download kali linux 
Shell :: brew install ngrok 
Shell :: how to install mongodb on ubuntu 22.04 
Shell :: command not found: neovim 
Shell :: date-fns npm package 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =