I am writing simple bash script (actually learning how to do it ) and i want this function to use just echo and sed and return exactly the same output. I found solutions with sed, they worked in console but did not work inside of script. (script is called with sudo, maybe it's important)This is my function:function strip{     echo $1 | grep -oP '[a-zA-Z0-9\+\-\=\ ]+' | head -n 1;}This is how it is suppsed to work  Input: -WallOutput: -Wall    Input: -O3%## -WallOutput: -O3    Input: %#$#$Output:   Can anyone show how would it look like using sed?
Using sed instead of grep to output only matching part of line
bash;shell script;sed;grep