Computing.Net > Forums > Unix > Unix - Search and replace

Unix - Search and replace

Reply to Message Icon

Original Message
Name: Niraj
Date: March 16, 2005 at 07:05:13 Pacific
Subject: Unix - Search and replace
OS: Solaris
CPU/Ram: 1GB
Comment:

Is it possible to do search and replace in unix
Like :

s/some date/current date/g

some date and current date both are in same format (dd/mm/yyyy hh:mm:ss)


My requirement is :
I am having a variable which holds last run date. After running my shell script I want to do update this variable with the current date.


Report Offensive Message For Removal

Response Number 1
Name: wollie
Date: March 17, 2005 at 01:50:35 Pacific
Subject: Unix - Search and replace
Reply: (edit)

Niraj,

save the current date to a second variable (adjust the date-format to your needs):

CURR_DATE=`date`
s/$LAST_RUN_DATE/$CURR_DATE/g

greet$
Wollie


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Unix - Search and replace

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software