Created
August 18, 2014 16:34
-
-
Save zhester/c697d43d3ca84b14f6be to your computer and use it in GitHub Desktop.
Copy a range of lines from a source file into another file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
############################################################################# | |
# | |
# Copy a range of lines from a source file into another file. | |
# | |
# Usage: | |
# range.sh <input> <first row> <last row> [<output>] | |
# | |
############################################################################# | |
# Go ahead and output what's going on to stdout. | |
set -e | |
set -x | |
# Initialize values according to user input. | |
_out=${4-'output'} | |
_start=`expr $3 - 1` | |
_count=`expr $3 - $2 + 1` | |
# Copy the desired range of lines to the output file. | |
( tail -n +$_start $1 | head -n $_count ) > $_out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment