5267b71995-08-09Fredrik Hübinette (Hubbe) #!/usr/local/bin/ulpc int main(int argc,string *argv) {
cb22561995-10-11Fredrik Hübinette (Hubbe)  int i;
5267b71995-08-09Fredrik Hübinette (Hubbe)  string file;
cb22561995-10-11Fredrik Hübinette (Hubbe) 
5267b71995-08-09Fredrik Hübinette (Hubbe)  if(argc<4) { write("Usage: rsif <from> <to> <files>\n"); return 0; }
cb22561995-10-11Fredrik Hübinette (Hubbe)  for(i=3; i<sizeof(argv); i++)
5267b71995-08-09Fredrik Hübinette (Hubbe)  {
cb22561995-10-11Fredrik Hübinette (Hubbe)  if(file=read_bytes(argv[i]))
5267b71995-08-09Fredrik Hübinette (Hubbe)  { if(-1!=strstr(file,argv[1])) {
cb22561995-10-11Fredrik Hübinette (Hubbe)  write("Processing "+argv[i]+".\n");
5267b71995-08-09Fredrik Hübinette (Hubbe)  file=replace(file,argv[1],argv[2]);
cb22561995-10-11Fredrik Hübinette (Hubbe)  if( mv(argv[i],argv[i]+"~") )
5267b71995-08-09Fredrik Hübinette (Hubbe)  {
cb22561995-10-11Fredrik Hübinette (Hubbe)  write_file(argv[i],file);
5267b71995-08-09Fredrik Hübinette (Hubbe)  }else{ write("Failed to create backup file.\n"); } } } } }>