I cannot seem to get a paste command to work in a bash script. The command pastes the contents of a range of files together and outputs a new combined file. This is what works outside the script if I wanted to paste file1 through file90 together:

paste file1 file{2..90} > combinedfile

Within the script, which has many variables and other commands pre and proceeding it, it does not. For simplicity, the code in essence:



let j=$START+1
paste file1 file{$j..$END} > combinedfile

It seems like there might be some kind of special notation to run this command using defined variables, but I do not know what it is. I've also tried the following:

paste file1 file{"$j".."$END"} > combinedfile
paste file1 file${$j..$END} > combinedfile
paste file1 file${"$j".."$END"} > combinedfile

I'll get errors like:

${$j..$END}: bad substitution
{847..902}: No such file or directory

Any help would be appreciated.

marked as duplicate by Kusalananda bash Jun 3 '18 at 15:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.