How to replace a parameter(variable) date value inside a text files daily with current date?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to replace a parameter(variable) date value inside a text files daily with current date?
# 1  
Old 08-27-2019
How to replace a date inside a text file daily with current date?

Hello All,

we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below:

abc.txt
------------------
Code:
line1
line2
line3
$$EDWS_DATE_INSERT=08-27-2019
line4
$$EDWS_PREV_DATE_INSERT=08-26-2019

I am trying to write a small command that can update these dates daily with current date but its not replacing the date value.
Code:
sed -i 's/$$EDWS_DATE_INSERT =.*/$$EDWS_DATE_INSERT="$(date `+%y%m%d`)"/' abc.txt

current result: $$EDWS_DATE_INSERT="$(date `+%y%m%d`)"

can anyone help with this ?

Thanks in Advance!

Last edited by vbe; 08-27-2019 at 04:24 PM.. Reason: code tags please
# 2  
Old 08-27-2019
Is this a duplicate post?

See example on other post:
Code:
sed -i 's/$$EDWS_DATE_INSERT *=.*/$$EDWS_DATE_INSERT='"$(date "+%y%m%d")"'/' abc.txt


Last edited by RavinderSingh13; 02-28-2020 at 02:05 AM..
This User Gave Thanks to rdrtx1 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies

2. UNIX for Beginners Questions & Answers

“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ Code: line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies

3. Linux

How to calculate the quarter end date according to the current date in shell script?

Hi, My question is how to calculate the quarter end date according to the current date in shell script? (2 Replies)
Discussion started by: Divya_1234
2 Replies

4. 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

5. Shell Programming and Scripting

Need to replace the date inside a node of several rdf files

Hi, I have a rdf zip file. This zip file consists of several *.rdf files. I need to replace the date (this is different for each rdf) inside the node "Date_de_Publication_Periodique" of these rdf files. e.g., awk '/Date_de_Publication_Periodique/ && /XMLSchema#date/' MM_NN-A1B1C1_ABC.rdf ... (11 Replies)
Discussion started by: Ribosome
11 Replies

6. Shell Programming and Scripting

Replace date on a line with current date

Hi Guys, I have a file with following content From 20121014 : To 20121014 Number of days : 1 1234 1245 1246 1111 Everyday i run my script i want to modify "To" date on the first line with current date. I have set the current date in script as RUN_DATE=`date -u +%Y%m%d` So i want... (9 Replies)
Discussion started by: jakSun8
9 Replies

7. Shell Programming and Scripting

Searching for unknown date inside the file and replace to new date

Hello, Iam a newbies to Shell scripting. Iam trying to replace the date inside the file to new date. is there anyway that we can just use the pattern to search as "..." I have many files want to replace with the same date, and each file contains different date. Thanks for your help. ... (2 Replies)
Discussion started by: Daro
2 Replies

8. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

9. Shell Programming and Scripting

Date One Week Ago From Given Date, Not From Current Date

Hi all, I've used various scripts in the past to work out the date last week from the current date, however I now have a need to work out the date 1 week from a given date. So for example, if I have a date of the 23rd July 2010, I would like a script that can work out that one week back was... (4 Replies)
Discussion started by: Donkey25
4 Replies

10. Shell Programming and Scripting

How to check date variable according to the current date?

Hi folks, I need to write a script that should activate a process according to the current hour. The process should be activatet only if the hour is between midnight (00:00) and 07:00. How should I create the condition? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies
Login or Register to Ask a Question