Name: Anonymous 2010-09-24 18:59
I'm taking a Unix class and we're supposed to write two scripts
The first one looks up every .c and .cc file in the current directory for the strings "printf" and "fprintf". If either string is found, the script adds "#include <stdio.h>" to the beginning of the file unless it's already been included.
The second compares two directories dir1 and dir2 (supplied as arguments) and copies and overwrites to dir1 from dir2 every file that is not present in dir1 or newer than its namesake in dir1.
I'm trying to write the first one right now, and I think I'm close, but I'm getting an error. I'm really new to shell scripting and *nix in general.
http://pastebin.com/RHmTdjYw
The first one looks up every .c and .cc file in the current directory for the strings "printf" and "fprintf". If either string is found, the script adds "#include <stdio.h>" to the beginning of the file unless it's already been included.
The second compares two directories dir1 and dir2 (supplied as arguments) and copies and overwrites to dir1 from dir2 every file that is not present in dir1 or newer than its namesake in dir1.
I'm trying to write the first one right now, and I think I'm close, but I'm getting an error. I'm really new to shell scripting and *nix in general.
http://pastebin.com/RHmTdjYw