Concatenating multiple text files into a single file in Bash

前端 未结 12 1616
眼角桃花
眼角桃花 2020-11-29 15:31

What is the quickest and most pragmatic way to combine all *.txt file in a directory into one large text file?

Currently I\'m using windows with cygwin so I have acc

12条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 15:59

    The most upvoted answers will fail if the file list is too long.

    A more portable solution would be using fd

    fd -e txt -d 1 -X awk 1 > combined.txt
    

    -d 1 limits the search to the current directory. If you omit this option then it will recursively find all .txt files from the current directory.
    -X (otherwise known as --exec-batch) executes a command (awk 1 in this case) for all the search results at once.

提交回复
热议问题