How to cat multiple files from a list of files in Bash?

后端 未结 6 889
故里飘歌
故里飘歌 2020-12-16 18:08

I have a text file that holds a list of files. I want to cat their contents together. What is the best way to do this? I was doing something like this but it

6条回答
  •  醉话见心
    2020-12-16 18:41

    I ended up with this:

    sed '/^$/d;/^#/d;s/^/cat "/;s/$/";/' files | sh > output
    

    Steps:

    1. sed removes blank lines & commented out lines from files.

    2. sed then wraps each line in cat " and ";.

    3. Script is then piped to sh with and into output.

提交回复
热议问题