Maulik Upadhyay
Maulik Upadhyay

Reputation: 127

column-wise merging of multiple files in specific order

I want to perform column-wise merging of multiple files considering the increasing order of file names. To be specific, I have renamed 163 files as 1.lrr, 2.lrr,3.lrr...163.lrr and I used following command to merge multiple files:

    Paste -d "\t" *.lrr > all_samples.lrr    

However, It combined column in some strange order of filenames. It started file merging with the file 100.lrr instead of file 1.lrr. Later on, it combined column from files 101.lrr until 109.lrr. Is it possible to modify this command so that it also considers numerically sorting of file names while merging the column?

Upvotes: 0

Views: 54

Answers (1)

Jacek Trociński
Jacek Trociński

Reputation: 920

Try this:

paste $(ls | grep -E "*.lrr" | sort -n) > all_samples.lrr

Upvotes: 1

Related Questions