How to update a date dynamically using sed?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to update a date dynamically using sed?
# 1  
Old 04-23-2014
How to update a date dynamically using sed?

hi guys,

i need to update a date in my config file via shell file
M using this statement but it is not working ...any suggestions
Code:
cat $CONFIG_FILE | sed -e 's/START_RUN_DATE=$START_RUN_DATE/START_RUN_DATE=$NEW_END_DATE/g' > srap_config_new.txt


Last edited by Franklin52; 04-23-2014 at 08:38 AM.. Reason: Please use code tags
# 2  
Old 04-23-2014
Try using double quotes instead of single quotes:
Code:
sed "s/START_RUN_DATE=$START_RUN_DATE/START_RUN_DATE=$NEW_END_DATE/g" "$CONFIG_FILE" > srap_config_new.txt

But make sure that $START_RUN_DATE and $NEW_END_DATE do not contain / characters or other characters special to sed .
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies

2. UNIX for Dummies Questions & Answers

Replace with last date update

Dear Masters, I have file input 20140901|Cross Nation|Asia 20140908|Cross Region|Europe 20140905|Cross Nation|Europe I want to replace column 1 with the last date update, so my output should be like 20140908|Cross Nation|Asia 20140908|Cross Region|Europe 20140908|Cross Nation|Europe ... (7 Replies)
Discussion started by: radius
7 Replies

3. Shell Programming and Scripting

Generating & executing the SELECT and UPDATE clause dynamically using shell script

Hi All, I need to write one shell script. The requirement is as follows. a) I am having list the employee names in a file stored in /tmp directory location as below /tmp/emp.txt b) and the contents are as below cat emp.txt ravi raj ram arun c) I need to connect to sybase... (1 Reply)
Discussion started by: Gowtham_giri
1 Replies

4. Shell Programming and Scripting

Downloading of dynamically generated URL using curl and sed

I've been attempting to use curl and sed to allow for downloading a file from a dynamically generated URL. I've been able to retrieve and save the HTML of the page that does the dynamic generation of the download URL using curl but I'm very new to sed and I seem to be stuck at this part. HTML: ... (1 Reply)
Discussion started by: schwein
1 Replies

5. Shell Programming and Scripting

Calculating expiry date using date,sed,grep

Hi, I would greatly appreciate it if someone can help me with my problem. I have a crawler which collects spam URLs everyday & this data needs to be published in a blacklist. Here's the catch: The "Time To Live" (TTL) for each URL is 3 months (or whatever for that matter). If i see the... (5 Replies)
Discussion started by: r4v3n
5 Replies

6. Fedora

Unable to Update Date

Hi everyone, Thanks for your help with this. I'm running an AWS EC2 instance (ami-2bc05345) and the time has been drifting. I have a different server using the same instance where the time is fine. NTP seems to be installed and be running (I uninstalled it and reinstalled it via Yum, just to... (4 Replies)
Discussion started by: AaronLS2
4 Replies

7. Shell Programming and Scripting

how to update date part with new increment date time

hi experts, my requirement is like this i need to develop a shell script to update date part with new incremental date time in file some 'X' which is kept at some server location incrementing every two hours.as i am new to this scripting i need support from u people,thanx in advance (1 Reply)
Discussion started by: amanmro
1 Replies

8. UNIX for Advanced & Expert Users

update files and preserve date

I have a bunch of historical files that need to be modified, as the file source announced there is an error in them which should be corrected. I am planning to use sed to do the mass update, but I would like to know if there is a way to preserve files last modified date/time, so later ls -ltr... (3 Replies)
Discussion started by: migurus
3 Replies

9. Shell Programming and Scripting

How to write current Date dynamically in a file

Hi, I have a requirement where I need to write the current date to the file. This remaining content of this file does not change and we use this file to concat with another one. Only thng is that I need to write the date to say, record number 10 of this file everyday. Can this be done in... (5 Replies)
Discussion started by: Sree_2503
5 Replies

10. UNIX for Dummies Questions & Answers

File update date

I am facing a peculiar problem with file update dates. In my network, if i telnet to machine A and check the files in dir test of machine A, the dates for the last update shown are true dates and upto date. If the same folder is checked through some other machine by sharing the test folder and... (2 Replies)
Discussion started by: amne
2 Replies
Login or Register to Ask a Question