let's say my script takes filenames starting from $3
e.g.
archive u 2342 a.txt b.png c.html d.js
archive u 2222 a.txt b.png
I want to zip all the files listed starting from $3 How can I do that?
thanks
let's say my script takes filenames starting from $3
e.g.
archive u 2342 a.txt b.png c.html d.js
archive u 2222 a.txt b.png
I want to zip all the files listed starting from $3 How can I do that?
thanks
The bash command shift
is your friend.
The script example.sh
#!/bin/bash
shift 3
echo $*
called with example.sh 1 2 3 4 5
will output 4 5
.
FIRST=$1
shift
SECOND=$1
shift
echo $FIRST
echo $SECOND
echo tar cf archive.tar "$@"
Input:
./test.sh 1 2 3 4 5
Output:
1
2
tar cf archive.tar 3 4 5