Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- SEARCH_PATTERN="$2"
- CACHE_DIR="$3"
- if [ -d "${CACHE_DIR}" ]
- then
- count=$(find ${CACHE_DIR} | wc -l)
- size=$(du -sh ${CACHE_DIR})
- echo "Total cached files: ${count}, size: ${size}"
- else
- echo "CACHE_DIR not defined"
- exit 1
- fi
- case "$1" in
- search)
- find ${CACHE_DIR} -type f | xargs strings -f 2>/dev/null | egrep -ow "KEY.*${SEARCH_PATTERN}.*"
- ;;
- delete)
- find ${CACHE_DIR} -type f |
- xargs strings -f 2>/dev/null |
- egrep -ow ".*KEY.*${SEARCH_PATTERN}.*" |
- while read x
- do
- x=(${x/:/})
- [ -f "${x}" ] && rm -v ${x}
- done
- ;;
- search_url_file)
- find ${CACHE_DIR} -type f | xargs strings -f 2>/dev/null | egrep -ow ".*KEY.*${SEARCH_PATTERN}.*"
- ;;
- list)
- find ${2} -type f | xargs strings -f 2>/dev/null | egrep -w "KEY.*"
- ;;
- default)
- exit 1
- ;;
- esac
- if [ -z "$CACHE_DIR" ]
- then
- echo "cache_dir not defined"
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement