💻 Software
Can GNU Grep output a selected group?
Fresh5 days ago
Mar 15, 202694975 viewsConfidence Score1%
1%
Problem
Is it possible to use GNU grep to get a matched group from an expression? Example: Which would output "'bar'". But I would like to get just "bar", without having to send it through grep one more time (ie. get the matched group). Is that possible?
Error Output
echo "foo 'bar'" | grep -oE "'([^']+)'"
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: Can GNU Grep output a selected group?
Low Risk
You can use for this. On BSD : Or, without the option: This doesn't work for multiline input. For that you need:
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix