1

I am trying to use this command:

type *.dump > total

in order to concatenate my .dump files into total.

However, the numbering of concatenation is wrong. For instance the files in order are:

cascade1.dump cascade10.dump cascade 11.dump

as opposed to 1, 2, 3, etc.

Can someone help me figure out the numbering?

2

GNU sort has a way to do natural sorting, called version sorting in its case:

-V, --version-sort          natural sort of (version) numbers within text

So you can do the following:

$ ls foo*
foo0  foo1  foo10  foo11  foo12  foo13  foo14  
foo15  foo2  foo3  foo4  foo5  foo6  foo7  foo8  foo9

$ ls foo* | sort -V
foo0
foo1
foo2
foo3
foo4
foo5
foo6
foo7
foo8
foo9
foo10
foo11
foo12
foo13
foo14
foo15

$ ls foo* | sort -V | xargs cat > total
4

This should work:

ls -rt *.dump | xargs cat > total

It orders the *.dump files by time before concatenation.

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.