erge text files ordered by numerical filenames in Bash

前端 未结 3 1096
南旧
南旧 2021-01-14 06:50

Is there any way to concatenate multiple text files in numerical order of the file names with one bash command ?

I tried this, but for some reason, the first three l

3条回答
  •  旧时难觅i
    2021-01-14 06:57

    ls *txt | sort -n | xargs cat > all.txt
    

    This gets a list of all the filenames and sorts it, then uses xargs to construct a command line from cat and the sorted list.

提交回复
热议问题