diff options
author | tv <tv@xso> | 2011-08-30 12:37:14 +0200 |
---|---|---|
committer | tv <tv@xso> | 2011-08-30 12:37:14 +0200 |
commit | a3cc6de32b3426cdcf9356c5c72df9e05f2a8468 (patch) | |
tree | 58d2251dd6fb3c50999e45137fc27744e99f7673 | |
parent | 22894de7a7ec26f36b190ebb0270ebc8f7d657a7 (diff) |
util hrefs: initial commit
The hrefs util extracts hrefs from html-stdin... we could use query for
this kind of extraction but hrefs is older and works already as fast as
light.. not^_^
-rwxr-xr-x | util/bin/hrefs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/util/bin/hrefs b/util/bin/hrefs new file mode 100755 index 00000000..3a1a51de --- /dev/null +++ b/util/bin/hrefs @@ -0,0 +1,20 @@ +#! /bin/sh + +_hrefs() { + sed -n 's/href="\([^"]\+\)"/\n&\n/gp' | + sed -n 's/^href="\([^"]\+\)"$/\1/p'; } + +_add_prefix_to_relative_hrefs() { + sed '/^http:/!s^'"$1"''; } + +_main() { + case $# in + (0) _hrefs;; + (1) _hrefs | _add_prefix_to_relative_hrefs "$1";; + (*) + echo "bad command line: $0 $*" >&2; exit 23;; + esac; } + +set -euf +_main "$@" +#### end of file. |