5

Let's say that I have 3 files in a directory:

apple.txt:

apple

beehive.txt:

beehive

zebra.txt:

zebra

If I concatenate this files with:

cat *.txt > all_files.txt

I do get:

apple
beehive
zebra

(I tested it on 5 files too, and I get the same behavior),

But my is this behavior guaranteed?

Akavall
  • 233

1 Answers1

8

From the POSIX shell specification of Filename Expansion

If the pattern matches any existing filenames or pathnames, the pattern shall be replaced with those filenames and pathnames, sorted according to the collating sequence in effect in the current locale.

So unless you have an unusual collation sequence in your locale, you can depend on it being alphabetical.

Barmar
  • 9,927