|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need Shell script help!
I have written a script that substitues one parameter for another parameter in a file. How can i fix it to still do this but without making a backup file if the file is unchanged.
This is what I have: #!/bin/csh set firstargument=$1 set secondargument=$2 set filename=$3 for $1 $3 do mv $3 $3.bak sed "s/$1/$2/g" $3.bak > $3 done Please Help! ![]() |
|
#2
|
||||
|
||||
|
one way would be to do a diff of the files, and if they're the same delete the backup
__________________
--Ax without exception, there is no rule ... heavyhaulage.ie The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones ![]() 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. -- Jamie Zawinski Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ... |
![]() |
| Viewing: Dev Shed Forums > Web Site Management > Scripts > Need Shell script help! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|