Sample Header Ad - 728x90

How can I iterate over the white space separated words returned by a command substition?

1 vote
1 answer
81 views
I have the following simple shell command: for x in $(echo one two three); do echo $x; done When executed, it simply prints one two three on *one* line, i. e. the result of the command substitution is evaluated as though I'd quote one two three, like so: for x in "one two three"; do echo $x; done However, I'd rather want the returned text of the command substitution to be returned as individual words, much like for x in one two three; do echo $x; done so that it prints one two three Is this somehow possible?
Asked by René Nyffenegger (2321 rep)
Sep 13, 2024, 03:02 PM
Last activity: Sep 14, 2024, 06:45 AM