Skip to content

Instantly share code, notes, and snippets.

@hacolab
Created August 2, 2019 14:38
Show Gist options
  • Save hacolab/29ed4994db8f53cee145c9b8e7b4d911 to your computer and use it in GitHub Desktop.
Save hacolab/29ed4994db8f53cee145c9b8e7b4d911 to your computer and use it in GitHub Desktop.
#!/bin/sh
USE_SED=
for arg in "$@" ; do
case $arg in
detail )
PICK_TAGS='<(title|updated|published|app:edited|app:draft|author)>|<(link|category|summary) '
;;
simple )
PICK_TAGS='<(title|published|app:draft|author)>|<(link|category) '
;;
entry )
PICK_TAGS='/<entry>/,/<\/entry>/'
USE_SED=true
;;
content )
PICK_TAGS='/<content /,/<\/content>/'
USE_SED=true
;;
formated)
PICK_TAGS='/<hatena:formatted-content /,/<\/hatena:formatted-content>/'
USE_SED=true
;;
-s )
USE_SED=true
;;
* )
PICK_TAGS="$arg"
;;
esac
done
if [ -n "$USE_SED" ]; then
sed -n "${PICK_TAGS}p"
else
sed -n '/<entry>/,/<\/entry>/p' \
| grep -E "${PICK_TAGS}|<[/]?entry>"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment