Skip to content

Instantly share code, notes, and snippets.

@spudtrooper
Created December 25, 2012 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spudtrooper/4373649 to your computer and use it in GitHub Desktop.
Save spudtrooper/4373649 to your computer and use it in GitHub Desktop.
Prints out every in between the first two arguments
#!/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