Reputation: 953
What's the best way to do
n=4
file1=firstfile.txt
file2=secondfile.txt
catlist="$file1" "$file2" 'file3.txt file'"$n"'.txt'
cat $catlist
Typically the gotchya with quoting is that you don't do enough. But I actually do want these to be their own parameters, so I'm not really sure how to go about this.
Upvotes: 1
Views: 69
Reputation: 6171
Never put more than one argument into a single string; you need an array to hold multiple arguments.
catlist=( "$file1" "$file2" file3.txt "file$n.txt" )
cat "${catlist[@]}"
Upvotes: 2