Horje
bash return n characters after match Code Example
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)




Shell

Related
git file line history Code Example git file line history Code Example
progress bar file.tar.xz extract Code Example progress bar file.tar.xz extract Code Example
grep return n characters before or after match Code Example grep return n characters before or after match Code Example
keep the container running and not exit directly Code Example keep the container running and not exit directly Code Example
linux check if dir is mounted Code Example linux check if dir is mounted Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10