In a directory I have a certain number of files. This could be 53 txt-files, but I could also have 123 files. The files have various random names, but all have the file-handle
I can get a list of all files with ls, and put this into a variable.
But I would like to partition the list in to multiple individual lists, each list with only 10 elements - i.e. a folder with 53 txt-files, should give me 6 lists. That is 5 lists with 10 filenames, and a 6th list with 3 file-names, and my example with 123 txt-files in a directory should give me 12 lists with 10 file-names, and a 13th list with only 3 file-names.
With my example with 53 txt-files: list no. 1 would hold the first file up until the tenth file , and list no. 2 would hold the eleventh file up to the twentieth file, and so on. I titled my question from the ith to jth element in a list, as I suppose other people might want to break down a list differently. Perhaps from the first file to the 100th file in a directory.
The ultimate goal is to be able to use these lists in a for do loop, and use the cat command, to write out the contents of ten files per list to one file per set of ten files - i.e. in my example with 53 files in a directory, this would give me 6 files. Where the first 5 files contains the content of the 50 original txt-files, and the 6th file contains the content of the last remaining 3 txt-files.
I have considered using the head or the tail command, but cannot quite work out how to specify ranges for these two commands.