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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Searching for unknown date inside the file and replace to new date
# 1  
Old 10-11-2012
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 "[0-9]..." I have many files want to replace with the same date, and each file contains different date.

Thanks for your help.

~Daro
# 2  
Old 10-11-2012
Please post a sample of the input file and the expected output.
And use code tags while posting code and data samples.
# 3  
Old 10-11-2012
Thanks for a quick response.
ex: file.txt
Today is 2012-10-04.

and I would like to change the date inside the file "2012-10-04" to new date. I know how to replace it as "s/olddate/newdate/", this way I need to get into the file to get the old date that I would like to change. But this ways takes time since I have many files and each file contains different date.
Please help me to use "pattern" instead.

Thanks.

Daro
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

How to replace a parameter(variable) date value inside a text files 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 ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies

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

4. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 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

Searching a file inside a .tar.gz file by date

Hi, I would like to ask if there is a way to search for a file inside a .tar.gz file without extracting it? If there is, is there a way to search for that file by date? Thanks! (4 Replies)
Discussion started by: erin00
4 Replies

7. Shell Programming and Scripting

ksh compare dates INSIDE a file (ie date A is > date B)

In KSH, I am pasting 2 almost identical files together and each one has a date and time on each line. I need to determine if the first instance of the date/time is greater than the 2nd instance of the date/time. If the first instance is greater, I just need to echo that line. I thought I would... (4 Replies)
Discussion started by: right_coaster
4 Replies

8. UNIX for Dummies Questions & Answers

Searching the date pattern in a file

Hi, I would like to search the pattern based on the date like "2010/08/15". I tried using / in the file giving /<<pattern>>. when i tried this it turns to /2010/+8, but not going to the pattern what ever i want. This is how the data in the file. INFO | jvm 1 | 2010/05/26 13:30:33... (5 Replies)
Discussion started by: venkatesht
5 Replies

9. Shell Programming and Scripting

searching a date and replacing with another date

I have a text file that i want to search through and pick out any dates that are formatted like MM/DD/YYYY and replace them with a date i want like 10/29/2009. any idea show i would do this?:) Snapshot of my text file: test4>s44syd5172>070>528>ENU>nongnuan>wanrawee>sr2330532>... (7 Replies)
Discussion started by: infiant
7 Replies

10. UNIX for Dummies Questions & Answers

searching a file by date...

It's possible to use "find" to search a file that was modified for example between 5/10/2004 and 7/11/2005? How can i do this? I saw there is option -mtime, but i don't understand how to use it in this case. Thanks (4 Replies)
Discussion started by: Kaminski
4 Replies
Login or Register to Ask a Question