rendered paste body#!/bin/bash########################################## feed1="http://animesuki.com/rss.php" # RSS feed #1# feed2="http://rss.a.scarywater.net/" # RSS feed #2# dir="~/feeds" # Where should I put the feeds?# parser="~/bin/parse" # (see below)#########################################mkdir $dir/tmp >> /dev/null; mkdir $dir/tmp/1 >> /dev/null; mkdir $dir/tmp/2 >> /dev/nullmkdir $dir/new >> /dev/null; mkdir $dir/new/1 >> /dev/null; mkdir $dir/new/2 >> /dev/nullmkdir $dir/old >> /dev/null; mkdir $dir/old/1 >> /dev/null; mkdir $dir/old/2 >> /dev/nullwget -o /dev/null -O $dir/tmp/1 $feed1wget -o /dev/null -O $dir/tmp/2 $feed2$parser $dir/new-1 >> $dir/new/1$parser $dir/new-2 >> $dir/new/2if [[ `diff $dir/new/1 $dir/old/1` || `diff $dir/new/2 $dir/old/2` ]]; thendiff $dir/new/1 $dir/old/1; diff $dir/new/2 $dir/old/2firm -R $dir/tmpmv $dir/new/1 $dir/old/1; mv $dir/new/2 $dir/old/2######################################################### begin parse.c ##########################################################include <string.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#define START "<title>"#define END "</title>"void walk(char * xml);int main(int argI, char ** argC){ struct stat * fileinfo = malloc(sizeof(struct stat)); int fd; char * BUF; fd = open(argC[1], O_RDONLY); fstat(fd, fileinfo); BUF = malloc(fileinfo->st_size); read(fd,BUF,fileinfo->st_size);// write(1,BUF,fileinfo->st_size); close(fd); walk(BUF); free(fileinfo); free(BUF); return 0;}void walk(char * xml){ char * xmltext = xml; char * start; char * end; while( xmltext != NULL ) { start = strstr(xmltext,START); end = strstr(xmltext,END); if(start == NULL) return; xmltext = start + strlen(START); *end = '\0'; printf("%s\n", xmltext); xmltext = end + strlen(END); }}