I need a shell/perl script to bring selected columns from all the files located in a directory and place them in a new file side by side.
File1:
a b c d
2 3 4 5
f g h i
..........
File2:
I II III IV
w x y z
..............
and so on many files are there...
My Output for selected columns(example 1 and 2) from source files should be:
a b I II..........................so on(here last file contents)
2 3 W X..........................so on(here last file contents)
f g
............ So on
and combine ( up to 12 -- but some characters might get swallowed up )
the 2-column-output-files with paste:
paste file1 file2 > file_comb.1
However, with lots of files... this will become a little bit of a challenge.
I'm willing to bet there's an easier approach to your actual problem.
meaning -- why do the first 2 columns need to appear in a new file?
and how many files are we actually talking about?
what is the final destination for this data file we're building?
how were the initial files created in the first place?
it seems if we redesign any one of these steps, we might be able to design a better end-to-end process.