On Mon, Oct 26, 2026 at 17:06:29 +0100, Franco Martelli wrote:
> Why splitting in multiple lines a sequence doesn't work: > > ~$ IFS=$'\n' echo {001..136} > > I would expect: > > 001 > 002 > 003 > ...
You've got a few conceptual mistakes here. First of all, IFS is not used by the echo command at all. Setting IFS simply has no effect on what echo does. The echo command always separates its arguments with a single space character. This is true whether it's the builtin shell echo, or the external /bin/echo command. And since it's the same either way, you can conclude that IFS would have no effect, since no external command sees it or respects it. IFS is used by the read command, and it's used by the shell when it does Word Splitting, or "$*" type expansions. But there is no Word Splitting happening here. Even if there were some, the way you're setting IFS (putting it into the temporary environment of the echo command) would not cause the words to be split the way you want. Cf. <https://mywiki.wooledge.org/BashFAQ/104> Brace expansion produces a list of words, and since your words have no characters in them that would cause further rounds of expansions, that list is passed directly to echo as an argument vector. You're running the command echo 001 002 003 ... and therefore echo writes the first argument, a space, the second argument, a space, and so on until the final argument, after which it writes a newline. Finally, I wonder what you intend to *do* with the output of echo here. Why do you want a stream of zero-padded three-digit numbers separated by newlines? Whatever you're going to do with this stream of characters, there's probably some easier or more efficient way to do it. But we need to know what the goal is, so we can advise you.