Get first word of string with sed
bash, sed
Solution
Just remove everything from the space:
$ echo "MAC evbyminsd58df" | sed 's/ .*//'
MAC
As you mention cut, you can use `cut` selecting the first field based on space as separator:
$ echo "MAC evbyminsd58df" | cut -d" " -f1
MAC
With pure Bash, either of these:
$ read a _ <<< "MAC evbyminsd58df"
$ echo "$a"
MAC
$ echo "MAC evbyminsd58df" | { read a _; echo "$a"; }
MAC
Problem
How can i cut with sed the following property to have only `MAC`? ``` MAC evbyminsd58df ``` I did this but it works in the other side: ``` sed -e 's/^.\{1\}//' ```