dotfiles

personal dotfiles
git clone anongit@rnpnr.xyz:dotfiles.git
Log | Files | Refs | Feed | Submodules

sfeed_unread (744B)


      1 #!/bin/awk -E
      2 
      3 # outputs unread feeds to stdout in the format:
      4 # feed name \t feed title \t feed url
      5 # if -c is specified only output a count of unread and total feeds
      6 
      7 function usage() {
      8 	print "usage: sfeed_unread [-c] sfeed_url_file feeds"
      9 	print "\t-c: print counts"
     10 	die = 1
     11 	exit(1)
     12 }
     13 
     14 BEGIN {
     15 
     16 	if (ARGC < 3)
     17 		usage()
     18 
     19 	if (ARGV[1] == "-c") {
     20 		cflag = 1
     21 		delete ARGV[1]
     22 	}
     23 
     24 	FS = "\t"
     25 	OFS = "\t"
     26 }
     27 
     28 # URL file: has only 1 field
     29 NF == 1 {
     30 	# generate lookup table of read URLs
     31 	u[$0] = 1
     32 	next
     33 }
     34 
     35 # feed file: compare with URL ($3) or id ($6)
     36 {
     37 	total++
     38 	if (length($3) || length($6)) {
     39 		if (u[$3] || u[$6])
     40 			read++
     41 		else if (!cflag)
     42 			print $7, $2, $3
     43 	}
     44 }
     45 
     46 END {
     47 	if (!die && cflag)
     48 		print "U: " (total - read) " T: " total
     49 }