1

I have several text files in a single folder, and I would like to merge only certain sequential files into one long one (where one file comes immediately after the next).

For example, I want to merge all files starting with test (so test1.txt, test2.txt, test3.txt, and so on) into one file named file.out, like so:

Stuff from test1
Stuff from test2
...
Stuff from testN

I tried cat * > file.out, but that merges everything, which is not what I want. How can I do this?

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172

1 Answers1

4
  • ways of using wildcards for cat
cat test[1-2].txt>out.txt  //matches any character in the set
cat test[!34].txt>out.txt  //matches any character not in the set
cat test?.txt>out.txt  //for a single character
cat test*>out.txt    // for any strings