How can I get the first string from a Bash list?
bash
Solution
Use cut:
echo $VAR | cut --delimiter " " --fields 1 # Number after fields is the
# index of pattern you are retrieving
Problem
I do have a Bash list (space separated string) and I just want to extract the first string from it. Example: ``` VAR="aaa bbb ccc" -> I need "aaa" VAR="xxx" -> I need "xxx" ``` Is there another trick than using a for with break?