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: "-Wall"
Output: "-Wall"
Input: "-O3%## -Wall"
Output: "-O3"
Input: "%#$#$"
Output: ""
Can anyone show how would it look like using sed?