Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help with shell scripting

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

Name: Anonymous 2010-09-24 20:26

>>7
>>8
>>9
I think I got it: grep -E '\<(printf|fprintf)'
The \< limits the match to the beginning of a word, so it won't match sprintf and the like.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List