Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash return n characters 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 :: Another active Homebrew update process is already in progress 
Shell :: install pandas in python 
Shell :: how to check git repository link 
Shell :: firewall-cmd remove port 
Shell :: sudo file manager rpi 
Shell :: npm fix deprecated packages globally 
Shell :: restart pulseaudio ubuntu 
Shell :: Get the size of all the directories in current directory in linux 
Shell :: git add all tracked files 
Shell :: crontab file location 
Shell :: linux decode base64 terminal 
Shell :: pip install django-allauth 
Shell :: Could not install from "HussainAppDataRoaming pm-cache\_npx15208" as it does not contain a package.json file. 
Shell :: django-cors-headers 
Shell :: install docker linux mint 
Shell :: unity logcat 
Shell :: change all crlf to lf vscode 
Shell :: restart ubuntu from terminal 
Shell :: restart nautilus from terminal 
Shell :: openssl version command 
Shell :: no console pyinstaller 
Shell :: Install django requirements from txt file 
Shell :: linux check gpu usage 
Shell :: enable epel repo centos 7 
Shell :: how to change swap space on ubuntu 
Shell :: how completely remove kde 
Shell :: linux check cpu core 
Shell :: how to install opencv in jupyter notebook windows 
Shell :: set by RBENV_VERSION environment variable 
Shell :: install ngrok 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =