On Tue, Aug 10, 2021 at 02:26:56PM +0100, Joe Pater wrote: > The attached bash script (named 'test'), when run on my laptop, > produces the following output: > > xyzerg > > Instead of the expected: > > Aabergxyz
OK, let's see if we can reproduce that. My initial thought is carriage return poisoning, but your attached "file" doesn't have CRs. Then again, that could be an artifact of an email system. > #!/bin/bash > > words=(`cat file`) > echo ${words[0]}xyz You really should be using mapfile for this, and quoting properly. #!/bin/bash mapfile -t words < file echo "${words[0]}xyz" > Aaberg > Aachen > aahing [...] With the script as I wrote it above, and those three lines in the input file, I get: unicorn:~$ ./foo Aabergxyz If I edit the file and put carriage returns at the end of each line, I get: unicorn:~$ ./foo xyzerg This matches your result. So, it would appear you have carriage returns in your input file.