Created
January 10, 2018 16:24
-
-
Save cGuille/4d232200c9b61fb873b9863b3a6cb5bb to your computer and use it in GitHub Desktop.
Slice a text file.
This file contains hidden or 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/env bash | |
# Output lines of stdin from $1 to $2. | |
# $1 and $2 can be line numbers or patterns. Examples: | |
# slice 10 20 # keep lines 10 to 20 | |
# slice /foo/ /bar/ # keep lines from the one matching foo to the one matching bar. | |
# slice 31703 '/<\/Product>/' # keep lines from number 31703 to the first one matching </Product> | |
sed "$1,$2!d" - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment