I am doing this script (with zsh, but I guess that it is not very important):
mylist=`seq 1 3`
for i in $mylist ; do echo "abc/$i" ; done
This gives :
abc/1
2
3
while I would like to see :
abc/1
abc/2
abc/3
A huge thanks to somebody that may find why it does not work/how to do.
mylist=( $(seq 1 3) )
(you can use backticks in place of$(...)
for the command substitution if you prefer, however it is considered deprecated) – steeldriver Jan 09 '21 at 21:37#! /bin/sh
at the top of the file. Depending on your system this may run ksh/zsh/bash/dash/ash, but in any case in a mode that disables such features as the one which is causing this behavior. N.B. on most systems /bin/sh is not completely POSIX compatible, but usually good enough. – ljrk Jan 10 '21 at 12:09$mylist
to${=mylist}
. That enables word splitting on the variable expansion. – JoL Jan 10 '21 at 12:49