Sponsored Content
Top Forums Shell Programming and Scripting searching a date and replacing with another date Post 302366211 by infiant on Thursday 29th of October 2009 05:31:45 AM
Old 10-29-2009
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?Smilie

Snapshot of my text file:
Code:
test4>s44syd5172>070>528>ENU>nongnuan>wanrawee>sr2330532>
THC>ms528enu>8>AB>>U11.0>10/26/2552>14:49:49>10/26/2552>16:01:53>
4317>0>871.00>36/6/0/p>8>1AB>4/1/0/p>80.00>>>>>>2AB>6/1/0/p>85.00>
>>>>>3AB>6/0/0/p>100.00>>>>>>4AB>6/1/0/p>85.00>>>>>>5AB>6/0/0/p>

Need to search and replace the highlighted text above with another date. Occurance will anywhere and many times in a text file .

Thanks
Please reply me ASAPSmilie

---------- Post updated at 04:31 AM ---------- Previous update was at 04:03 AM ----------

I dont want to update time. need only date

Last edited by Franklin52; 10-29-2009 at 07:33 AM.. Reason: Please use code tags!
 

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

sed replacing date

I found this code on here in another thread (which I can't find now). The code works on normal text, but not for a date in the format of "mm/dd/yyyy". I assume it has to do with the "/". I am using korn shell. Any ideas? sed 's/${OldDate}/${NewDate}/g' < file > file.new mv file.new file (2 Replies)
Discussion started by: stringzz
2 Replies

3. Shell Programming and Scripting

Issue searching for Date

I have an issue regarding searching for old dates. At the moment I search a field within a file for the last 3 days from the system date: using today as 25/02/2010 DD=$(expr `date +%d` - 1) DD1=$(expr `date +%d` - 2) DD2=$(expr `date +%d` - 3) MTH=`date +"%m"` YR=`date +"%Y"`... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

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

5. UNIX for Dummies Questions & Answers

Searching by date range from filenames

Hello all, i have tons of files in folder named like this (yyyymmdd): bookcollection20100729 bookcollection20100730 bookcollection20100731 bookcollection20100801 bookcollection20100802 etc. I need to find files with date range in there names lets say from 2010.07.30 - 2010.08.02 ... (10 Replies)
Discussion started by: Whit3H0rse
10 Replies

6. Shell Programming and Scripting

Replacing / by - in date

Dear Friends, Following is manupulated output of our script. e.g. lkme_lpst 2 Pur_dt 31/12/2011 bl_dt 01/02/2011 rt_dt 02/02/2011 prod_btch 19/1452147-5210 We further want to manupulate it and want to replace / by - i.e. Lkme_lpst 2 Pur_dt 31-12-2011 bl_dt 01-02-2011... (7 Replies)
Discussion started by: anushree.a
7 Replies

7. Shell Programming and Scripting

Converting a date to friday date and finding Min/Max date

Dear all, I have 2 questions. I have a file with many rows which has date of the format YYYYMMDD. 1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too. 2. After converting the date to... (10 Replies)
Discussion started by: 2001.arun
10 Replies

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

9. Shell Programming and Scripting

Replacing Date in the file with Create date and timestamp

Hello, I have files that with a naming convention as shown below. Some of the files have dates in the file name and some of them don't have dates in the file name. imap-hp-import-20150917.txt imap-dell-gec-import-20150901.txt imap-cvs-import-20150915.txt imap-gec-import.txt... (8 Replies)
Discussion started by: Saanvi1
8 Replies

10. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies
DP(8)                                                                [nmh-1.5]                                                               DP(8)

NAME
dp - parse dates 822-style SYNOPSIS
/usr/lib/mh/dp [-form formatfile] [-format string] [-width columns] [-version] [-help] dates ... DESCRIPTION
Dp is a program that parses dates according to the ARPA Internet standard. It also understands many non-standard formats, such as those produced by TOPS-20 sites and some UNIX sites using ctime(3). It is useful for seeing how nmh will interpret a date. The dp program treats each argument as a single date, and prints the date out in the official 822-format. Hence, it is usually best to enclose each argument in quotes for the shell. To override the output format used by dp, the -format string or -format file switches are used. This permits individual fields of the address to be extracted with ease. The string is simply a format string and the file is simply a format file. See mh-format(5) for the details. Here is the default format string used by dp: %<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%> which says that if an error was detected, print the error, a `:', and the date in error. Otherwise, output the 822-proper format of the date. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
None SEE ALSO
ap(8), Standard for the Format of ARPA Internet Text Messages (RFC-822) DEFAULTS
`-format' default as described above `-width' default to the width of the terminal CONTEXT
None BUGS
The argument to the -format switch must be interpreted as a single token by the shell that invokes dp. Therefore, one must usually place the argument to this switch inside quotes. MH.6.8 11 June 2012 DP(8)
All times are GMT -4. The time now is 03:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy