![]() |
|
|
|
|
|||||||
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Change of directory thru script | shiningram | Shell Programming and Scripting | 4 | 03-29-2007 12:30 AM |
| Change Directory via a script? | George Borrmann | Shell Programming and Scripting | 3 | 10-09-2006 05:13 PM |
| script to ftp file (ip change) | happyv | Shell Programming and Scripting | 2 | 09-19-2006 12:50 AM |
| Help with multiple file rename - change case of part of file name | steve7 | UNIX for Dummies Questions & Answers | 7 | 06-30-2005 10:41 AM |
| How do I change users in a script??? | chorgan | Shell Programming and Scripting | 2 | 02-15-2002 07:53 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
script to change value in file
Hi,
I have a parameter file and it contains following items $ cat TransactionParams From_Date_Parm=2005-02-25 To_Date_Parm=2005-05-25 Extract_Root_Parm=/detld1/etl/ascential/Ascential/DataStage/Projects/CTI_London/IAM Extract_Type_Parm=Transaction EDW_Database_Parm=hdw_erks EDW_User_Parm=t449206 FTP_Path_Parm=/detld1/etl/ascential/Ascential/DataStage/Projects/CTI_London/IAM/ftp/ FTP_User_Parm=t449207 FTP_Password_Parm=Magdog,123 Date_Run_Parm=06042005 Sequence_ID_Parm=1 Daily_Sequence_Parm=1 ParameterFileParm="nothing" Send_FTP_Parm=Y What i should do is i need to write a script which should search for systemtime (based on the time we run) and if it is less than 12'0 clock from From_Date_Parm should be replaced with sysdate - 1 (2005-06-20) and To_Date_Parm as sysdate (2005-06-21) else if it is greater than 12 and less than 24 then From_Date_Parm = sysdate (2005-06-21) How can i change the appropriate values using script. I am new to unix and i want the code which does the corresponding job. Thanks in advance. cheers, gops |
| Forum Sponsor | ||
|
|
|
|||
|
Quick & very dirty solution
I don't have time to write the code for you but you could do the following:
When updating... grep the file for the original value, generate new value... pipe the file through sed and insert new value using s/// substitution. This in no way counters the issue of file locking and temporary re-writes (i.e. output of sed overwriting original input). You can get away with it on small files but I wouldn't risk it in a professional system. Alternatively, use Perl and the "profile" handler header that acts just like Get Private Profile in Windows API. |
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|