2

I have many subfolders from my current operating directory. In each subfolder, there is a file called "total"

"total" contains 2 columns of data, and remember there are many "total" files, each in the different subfolders.

I have been tirelessly going into each folder, opening each total, and pasting into a spreadsheet. Could I Expedite the process though?

Can I concatenate all files named "total" in all the subfolders into a single file called "total all" in my current folder, which has all the data next to one another?

In other words the 1st two columns of my new file would be the 2 columns from the first subfolder (in alphabetical order), columns 3 and 4 would be the data from the total file next in line, etc.

Any help is appreciated!

1

find . -maxdepth 1 -name total | sort | xargs paste

8
  • Are you sure this only goes into one directory below? It seems to be taking way to long and I am wondering if it is trying to concatenate all files with this name on my computer. Also, I need them to be next to each other. This has 2 columns only with each file pasted below the previous one – Jackson Hart Jan 13 '16 at 20:29
  • I used mindepth to fix the first issue. But how do i join them horizontally and not vertically? – Jackson Hart Jan 13 '16 at 20:35
  • I didn't "ding you" whatever that means. And it's not my downvote. It's up to you to take my suggestion on board and improve your answer. By the way the OP doesn't seem very happy with your answer, so that's another reason to improve it. – DavidPostill Jan 14 '16 at 15:38
  • @JacksonHart -- I missed the original requirement for columns. Use paste instead of cat. By default it does tab separation, but you can change that if you want to generate a CSV. – BowlesCR Jan 14 '16 at 15:44
  • @BowlesCR What order is it pasting them in? It does not appear to be alphabetical – Jackson Hart Jan 14 '16 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.