view bin/basicopt @ 453:c3bfb45757e9

FreeBSD grep is GNU grep. Well, up to 9.x.
author Edho Arief <edho@myconan.net>
date Fri, 15 Feb 2013 18:18:18 +0900
parents 5bafb912837e
children 7f5234a312f7
line wrap: on
line source

#!/bin/sh
get_filename() {
	printf "%s\n" "$*" | sed -e 's/^\(.*\)\.[^.]*$/\1/'
}
get_extension() {
	if [ -n "$(printf "%s\n" "$*" | sed -e 's/^[^.]*//')" ]; then
		printf "%s\n" "$*" | sed -e 's/^.*\(\.[^.]*$\)/\1/'
	else
		printf "%s\n" ""
	fi
}