File: query.sh

package info (click to toggle)
ii 1.7-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 124 kB
  • ctags: 87
  • sloc: ansic: 433; makefile: 82; sh: 18
file content (29 lines) | stat: -rwxr-xr-x 904 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# ----------------------------------------------------
# Nico Golde <nico@ngolde.de>
# License: do whatever you want with this code
# Purpose: locate new queries for the ii irc client
# ----------------------------------------------------

IRCPATH=$HOME/irc
TMPFILE=$IRCPATH/queries.tmp

if [ ! -f $TMPFILE ]; then
    touch $TMPFILE
fi

echo "searching new query data"
for i in `find $IRCPATH -newer $TMPFILE -name 'out'`
do
    grep -v '\-!\-' $i  > /dev/null 2>&1 # if file doesnt just contain server stuff
    if [ $? -ne 1 ]; then
        # strip server, nickserv and channel out files
        echo $i | egrep -v -i "nickserv|#|$IRCPATH/(irc\.freenode\.net|irc\.oftc\.net)/out" > /dev/null 2>&1
        if [ $? -ne 1 ]; then
            printf "new data in: %s\n========================================================\n" "$i"
            tail -5 $i
        fi
    fi
done

touch $TMPFILE