Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 3
    Did you mean to use echo -n instead of echo -e? Commented Jul 23 at 17:17
  • @terdon I tried both echo -e and echo -n. -e for many tries with "\n", and possibly I've copied the wrong example. But given the answer from Stehen Kitt, this doesn't make a big difference, only, with -n the last words F and E are not separated. The answer implicitly explains that, too. Commented Jul 24 at 9:23
  • echo -e is the same as echo for this case, so it's weird to use an option that doesn't do anything. To put a space separator after every element including the last one, use echo -n 'A B C D E F ' (which is exactly what Stephen is doing with printf '%s ' with multiple args, vs. I'm using one quoted string so all the spaces between elements are a literal part of that string for clarity. I could also have done echo -n A B C ... F '' with an empty final element to get echo to invent a final space after the F, before the empty string.) Commented Jul 24 at 20:58
  • @PeterCordes as I explained to @ terdon, the "-e" is an accidental remnant form one of my many tries. And you are right with your solution to add an extra separator at the end of the line, that is what I finally did. Easy enough, once we understand what's going on. Commented Jul 25 at 5:37
  • 1
    Right, might as well leave it now. But the best thing would have been to remove the -e after it was first pointed out. Commented Jul 26 at 18:04