Jump to content

Incgrepac ✓ ❲REAL❳

while [[ $# -gt 2 ]]; do case "$1" in --role) ROLE="$2"; shift 2 ;; --since) SINCE="$2"; shift 2 ;; *) shift ;; esac done if [[ -n "$ROLE" ]]; then check_role "$ROLE" fi Incremental grep: find lines in files modified after $SINCE find "$TARGET" -type f -newer "$SINCE" -exec grep -H "$PATTERN" {} ; Update state file date "+%Y-%m-%d %H:%M:%S" > "$STATE_FILE"

#!/bin/bash # incgrepac - Incremental grep with access control # Usage: incgrepac [--since TIMESTAMP] [--role ROLE] PATTERN FILE STATE_FILE="/tmp/incgrepac_lastrun" PATTERN="$1" TARGET="$2" check_role() local required_role="$1" if ! groups Incremental: get last modified timestamp get_lastrun() if [[ -f "$STATE_FILE" ]]; then cat "$STATE_FILE" else echo "1970-01-01 00:00:00" fi Parse arguments ROLE="" SINCE=$(get_lastrun) incgrepac

×
×
  • Create New...

This website uses cookies, as do most websites since the 90s. By using this site, you consent to cookies. We have to say this or we get in trouble. Learn more.