'get n latest arguments shell script

So I have some script

files="${!#}"
if [[ -n "$files" ]]
then
        do some instructions
else
        do some instructions
fi

I really need to how to get n arguments from the 7th argument or N argument. Something like this:

var1=arg1 arg2 arg3 .... arg7 argN argN+1 ...

Capture them in a variable like this:

var1= argN argN+1 ....


Solution 1:[1]

Use shift to remove the first N-1 arguments, then $@ will contain the remaining arguments.

shift 6
if [ $# -ne 0 ]
then
    files=("$@")
    # do something with $files
else
    # do something else
fi

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Barmar