newb at scripting how would I do this?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting newb at scripting how would I do this?
# 1  
Old 09-22-2011
newb at scripting how would I do this?

Hi guys.

I have been lurking for quit some time attempting to learn on my own but I have reached an impasse.

I need to extract specific details from from a text file that I get and parse it out into separate files with the name of each individual and the date it was proccess. Then within each file file it with the pertaining info for that user. In this case it is the cell phone usage and cost for them that is in the file.

I have attached the file for anyone who wishes to look at it.
the monthly file is what I get every month.
the other is what I am trying to make the output look like including the name.

I have tried everything I can think of but since I am a noob without any skill I have run into an impasse.

I can't even figure out a way to skip the first 11 lines and the very last line.

My largest concern is learning the logic behind doing this.
However I have banged my head on the wall Smilie for 3weeks with very little progress.

Any help would be appreciated.
# 2  
Old 09-22-2011
Try this...
Code:
awk -F\" 'BEGIN{ printf("%-15s\t%-10s\t%-20s\t%-10s%-20s\t%-20s\t%-20s\t%-20s\t%-20s\t%-20s\n",
"Name","Number","Service Plan Name","Charge","Phone Daytime Usage","Phone Daytime Charges","Phone Evening Usage",
"Phone Evening Charges","Phone Weekend Usage","Phone Weekend Charges")} /Total/{next} /^"Name/{t=1;next} 
{if(t>0){printf("%-15s\t%-10s\t%-20s\t%-10s%-20s\t%-20s\t%-20s\t%-20s\t%-20s\t%-20s\n",$2,$4,$6,$7,$8,$9,$10,$11,$12,$13)}}' 
input_file

--ahamed
# 3  
Old 09-22-2011
Quote:
Originally Posted by ahamed101
Try this...
Code:
awk -F\" 'BEGIN{ printf("%-15s\t%-10s\t%-20s\t%-10s%-20s\t%-20s\t%-20s\t%-20s\t%-20s\t%-20s\n",
"Name","Number","Service Plan Name","Charge","Phone Daytime Usage","Phone Daytime Charges","Phone Evening Usage",
"Phone Evening Charges","Phone Weekend Usage","Phone Weekend Charges")} /Total/{next} /^"Name/{t=1;next} 
{if(t>0){printf("%-15s\t%-10s\t%-20s\t%-10s%-20s\t%-20s\t%-20s\t%-20s\t%-20s\t%-20s\n",$2,$4,$6,$7,$8,$9,$10,$11,$12,$13)}}' 
input_file

--ahamed

Wow thank you so much.
that was one heck of a fast response.
in 3 weeks I could not figure this out. and you did it in 15mins Smilie

I have so much to learn

Again thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Newb Help, need to image one HD to another

Hello, I am totally new to Unix We have a piece of test equipment, three of them actually, that run HP-UX 9.0 from like 1994. We had backup tapes with procedures to load the OS and our test software, but the 16-track tapes are corrupt now. HP will not support it, they dont have it anymore,... (11 Replies)
Discussion started by: Newball80
11 Replies

2. Shell Programming and Scripting

Help a newb with sed?

So here is my problem: I need to do a sed search and replace on the following: variable_blah_STATUS replaced with "replace string". sed 's/variable_blah_STATUS/replace string/g' works great but there is a catch. The catch is that I need to check and not replace variable_blah_STATUS... (3 Replies)
Discussion started by: phreezr
3 Replies

3. Shell Programming and Scripting

newb help needed

hi all, im working on a script that needs to read in a file, search for a string of text within that file, and if the string is found, do something. so i know i need to use an if-then statement, but how do i test for the existence of a string within the file? any help would be greatly appreciated. (6 Replies)
Discussion started by: mdlearnest
6 Replies

4. UNIX for Dummies Questions & Answers

Newb here....Someone spying on me?

Hey all. I'm brand spankin' new here to the board. I'm also a novice at Unix. I've been using it for about 1 year now but I haven't really expanded my abilities since I learned the basics. I am in school and I mainly just use Unix to submit stuff to assignment directories and use it to compile my... (3 Replies)
Discussion started by: andre2000
3 Replies

5. Shell Programming and Scripting

Newb scripting question, I get the error script not found

This is probably a really simple problem, but goes easy on me I'm still a newb. The problem I have is that a script (we'll call it script.script) I edited won't run for some reason, I get the error "ksh: script.script: not found" The location of my script is as follows: /home/users/arkitech ... (3 Replies)
Discussion started by: Arkitech
3 Replies

6. UNIX for Dummies Questions & Answers

Ok I'm a Newb, Please Help

I am wanting to download the Linux Program. When i go to download it I see several things to download. What do i download exactly? Then what do I do to install it. Also I have partitioned my hard drive to make way for Linux on the other part to play with it, will any problems arise from this? I... (3 Replies)
Discussion started by: Seeto
3 Replies

7. UNIX for Dummies Questions & Answers

Newb question

I don't even know if this should go here but I just would like to know what this means: d0e45878043844ffc41aac437e86b602 I know absolutely nothin' about UNIX, and I found this in a SQL table in a board I run. Someone please tell me what that is in "normal" mode. Pardon me for my... (4 Replies)
Discussion started by: daeglin
4 Replies

8. UNIX for Dummies Questions & Answers

help for a newb

ok i just installed FreeBSD 4.8 on a computer i had lying around and it was working ok but then when i tried to set up KDE's xdm (kdm) i think i must have configured the login manager wrong because i cant login through the kdm and therefore i can log in to BSD at all?! please can someone help me... (5 Replies)
Discussion started by: h3x
5 Replies

9. UNIX for Dummies Questions & Answers

100% newb - please help

I run windows 2000 right now. I want to learn how to use unix/linux. How do i go about installing Unix/Linux? What's the easiest version to install? Where can i get it? Is my Hardware Compatable? How do i partition my Hd? HELP!!!!!:confused: (6 Replies)
Discussion started by: Rawdawg
6 Replies

10. UNIX for Dummies Questions & Answers

The biggest newb ever...

Hi, all you unix people. I am a pretty advanced windows user, but I am curious about unix. Is there any reason I should attempt to acquire some form of unix for my home computer system? What sort of things is unix useful for? Unix is open source, right? Assuming that to be the case, I infer that... (3 Replies)
Discussion started by: BoneMalone
3 Replies
Login or Register to Ask a Question