Created
December 25, 2012 15:04
-
-
Save spudtrooper/4373649 to your computer and use it in GitHub Desktop.
Prints out every in between the first two arguments
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
#!/bin/sh | |
# | |
# Prints out every in between the first two arguments: | |
# | |
# Example: | |
# | |
# % inbetween '- - \[' '\]' # Dates from an apache log file | |
# | |
fst=$1; shift | |
if [[ x$fst = 'x' ]]; then | |
echo "First delimiter required" | |
exit 1 | |
fi | |
snd=$1; shift | |
if [[ x$snd = 'x' ]]; then | |
echo "Second delimiter required" | |
exit 1 | |
fi | |
sed -e "s/.*$fst//g" -e "s/$snd.*//g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment