1

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:

#!/bin/bash

START=1
END=90

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.

Johnny
  • 95

0 Answers0