UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old June 5th, 2004, 01:07 AM
knuckle99 knuckle99 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 knuckle99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
awk problems

I have 3 problems I need to figure out. I am just getting started using awk so any examples or solutions would be greatly appreciated.

1. I need to create a total sales report for the year. The data file has commas so I cannot add the numbers easily. How do I remove the commas, add the numbers and then reinsert the commas for the final report?
The data file has this format:
January<tab><tab>123,456.89

2. I need to find the differences in time between two checkout times.
The data file is in this format:
034023<tab>052030
I need to print out a report in this format:
hh:mm:ss of column 1<tab>hh:mm:ss of column 2<tab>hh:mm:ss of difference between column 1 and column 2

3. I need to write a script that will validate data:
The data file is in this format:
login nameassword:user ID:Group ID:User Info:Home Directory:Login Shell

The data is validated if -
a - the line must have 7 fields
b - The first field can be alphnumeric
c - The second field should not be empty
d - The 3rd and 4th fields should be numeric
e - No restriction on the 5th field
f - The 6th and 7th fields should start with a "/"

The script should create a report and appends any line that violates any of the critera with the reason for violation.

I know all of you are very talented with awk and can help me out. I really appreciate it. I just don't have any good examples or solutions to get me started.
Thanks in advance.

Reply With Quote
  #2  
Old June 10th, 2004, 02:21 AM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
homework?

did you just dream these questions up? If not, then there are two other possible scenarios - 1) you read them from an awk text book (the only ones I know of are the A. W. & K one and the O'Reilly one) - in which case, try reading the book, or 2) homework.

Have you even attempted this? What problems are you having? Why are you coming here when you haven't even shown a single line of code nor an error message or any inclination what so ever to attempt the problem yourself. These first time posts from n00bs irritate us enough for us to sit and write 2 paragraph-long rants in return.

christo

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > awk problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway