💻 Software
Better way to do "echo $x | sed ..." and "echo $x | grep ..."
Fresh5 days ago
Mar 15, 202623415 viewsConfidence Score0%
0%
Problem
I often find this in scripts (and, I have to admit, write it myself): or Consider "foo" to include some regex stuff. I feel that there should be - and most likely is - a better way to phrase this, one that does not involve two commands and a pipe but wraps the thing into some more compact expressio…
Error Output
a=$(echo "$x" | sed "s/foo/bar/")
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: Better way to do "echo $x | sed ..." and "echo $x | grep ..."
Low Risk
Unless you assume a specific shell, there is no better way to do this than “pipe echo to tool” (or just a “tool” itself like expr); it is all you can really count on with the traditional Bourne shell and/or the POSIX shell. If you consider other she…
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix