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

Viewed 31302

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 seems overly complex:

let count=0
while read -r LINE
do
    [[ "$line" =~ ^#.*$ ]] && continue
    if [ $count -ne 0 ] ; then
        file="$LINE"
        while read PLINE
        do
            echo $PLINE | cat - myfilejs > /tmp/out && mv /tmp/out myfile.js
        done < $file
    fi
    let count++
done < tmp

I was skipping commented lines and running into issues. There has to be a better way to do this, without two loops. Thanks!

6 Answers
Related