I do the following in my scripts:
~/tmp$ cat quick.sh
#!/bin/bash
TEXT="Hello World"
KEY=$(echo ${TEXT} | sed -r "s/(^[^ \t]+).+/\1/")
echo ${TEXT}
echo ${KEY}
~/tmp$ ./quick.sh
Hello World
Hello
How can I extract the first word from a string just with tools BASH provides?
Using the
${param%%word}Parameter Expansion