Sample data (foo)
line 1
line 2
line 3
line 4
line 5
line 6
To get the desired lines hardcoded I have used
sed -n '1,3p' foo
Which returns to expected outcome
line 1
line 2
line 3
Now I need to a script where the range1, range2 & file-name are taken as command-line arguments. So i tried
#!/bin/bash
sed -n '$1,$2p'
When running the scripting using
sh print_lines.sh 2 4 foo
I get the following error
sed: -e expression #1, char 2: unknown command: `1'
Any ideas? Thanks