
April 24th, 2006, 08:17 PM
|
|
Registered User
|
|
Join Date: Apr 2006
Posts: 4
Time spent in forums: 1 h 13 m 44 sec
Reputation Power: 0
|
|
|
Shell Scripting Newbie Help
I'm taking an online course, intro to unix, and have another assignment to complete before the semester ends. I understand most of it, but I have hit a brick wall on this one. Basically I have two make two scripts, with the second having an extra parted added which I cannot figure out.
Here is my first script:
Quote: #!/bin/sh
replacethis=$1
withthis=$2
file=$3
mv $file $file.bak
sed -e "s+$replacethis+$withthis+g" $file.bak |
I need to edit this so that it ONLY updates the file IF something was changed i.e. the two files are different. I have a decent understanding of how to use if statements and such in scripting and I've used commands such as "diff" straight in the shell, but I'm not sure how to tell the script if there is a difference or not. I don't necessarily need an answer given to me if that is too much to ask, but any pointers to guide me in the right direction would be great. Thanks in advance for any help!
|