473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

extracting a date from a text file using sed

114 100+
Help needed with shell script using the sed command.
Need to extract a date from a text file. Each record contains the text "Date Entered:" and following that literial is a space followed by mm/dd/yyyy and two spaces. There are occasions when the literal is present with no date, just 3 spaces following it.

I need to extract that date and place it in a variable so that it may be used when writing out that record to a new file. There are other variables being extracted but the date is what I am having problems with. I am creating a tab delimited file that will be used as a table load in a SQL database.

Anyone know how to use sed to do this, the script already exist I just need to add the correct code to this script.

Thanks for any help.
Jan 26 '07 #1
1 5921
Motoma
3,237 Expert 2GB
Help needed with shell script using the sed command.
Need to extract a date from a text file. Each record contains the text "Date Entered:" and following that literial is a space followed by mm/dd/yyyy and two spaces. There are occasions when the literal is present with no date, just 3 spaces following it.

I need to extract that date and place it in a variable so that it may be used when writing out that record to a new file. There are other variables being extracted but the date is what I am having problems with. I am creating a tab delimited file that will be used as a table load in a SQL database.

Anyone know how to use sed to do this, the script already exist I just need to add the correct code to this script.

Thanks for any help.
Expand|Select|Wrap|Line Numbers
  1. sed 's/\(.\) \([0-9]\{2\}\/[0-9]\{2\}\/[0-9]\{4\}\) \(.\)/\2/'
  2.  
Jan 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gnaneshwar Babu | last post by:
Hi I am facing a problem with extracting event logs of win32 to a file. Am using the following code to extract eventlogs to file use Win32::EventLog; $handle=Win32::EventLog->new("System",...
2
by: Shawn | last post by:
I have an XML file that contains nodes and I'm having no problem extracting the information using ASP. However I can't seem to get the ID number from the deliverrequest node from the example below....
2
by: Aleander | last post by:
Hi! I have to write the records of a vector in a file, e and then open this file to extract the record to refill the vector. My program has two class: Visita(Appointment) and Data(date). The...
2
by: Kevin K | last post by:
Hi, I'm having a problem with extracting text from a Word document using StreamReader. As I'm developing a web application, I do NOT want the server to make calls to Word. I want to simply...
6
by: saleemahmad70 | last post by:
Hi.. I am stuck with a problem where I need to extract some information from a File in C++.e.g File size,date of creation, Location on the Disk etc. I haven't been able to find any particular...
1
by: jerryyang_la1 | last post by:
I'm reading in a CSV and displaying using the code below: $users = file("text.txt"); echo "<table border='1' width='75%' align='center'>"; echo "<tr>"; echo "<td width='33%'...
7
by: whitsey | last post by:
Help! I am trying to write an SQL statement (without much luck) to extract the total number of searches and orders from a particular customer, grouped into days/months/weeks (depending on the...
4
by: dexter48 | last post by:
Hi I'm searching for a string occurance in a text file. I find the string ok and write the results to a log file. But on the line above is also some information I need. How can i get that. The string...
4
by: poolboi | last post by:
hi guys i've having some problem extracting data from a text file example if i got a text file with infos like: Date 2008-05-01 Time 22-10 Date 2008-05-01 Time 21-00 Date 2008-05-02 Time...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.