tail: cannot open ‘+2’ for reading: No such file or directory

Viewed 13752

I am trying to print the content of the file(myfile) from the line no 2 to line no 5 through the script.sh. The script is not able to open the file from the position 2.And also contents are printing from the 1st line to 4th line.Below are the file contents, command and the output of the command.

$cat myfile
SR.N0.  Details
Name    XXXX
DOB     XXXX
DOJ     xxxx
JOB     XXXX
DOMAIN  XXXX
COMPANY XXXX


$cat script.sh
#!/bin/bash
tail +$1 $3 | head -n$2

$./script.sh 2 6 myfile
tail: cannot open ‘+2’ for reading: No such file or directory
==> myfile <==
SR.N0.  Details
Name    XXXX
DOB XXXX
DOJ xxxx
JOB XXXX
1 Answers
Related