Clean Text File


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Clean Text File
# 1  
Old 08-24-2006
Clean Text File

HI,
I have a file which comes from crystal reports in the below format.
I need to clean the file so that i will only have the columns(deptid,empid,ename,sal) and the data below the column names.
There is a bug in the repoting tool( we only see page1-1 for every department).The rundate change dynamically and the number of departments changes dynamically.


Rpt 001 - Employee Master RunDate:08/03/2006
Parameter
Employee: ALL
Sal: ALL


deptid empid ename sal

100 1 Thomas 2000
100 2 Brian 7000


Page -1 of 1




Rpt 001 - Employee Master RunDate:08/03/2006
Parameter
Employee: ALL
Sal: ALL

deptid empid ename sal

200 1 Thomas 2000
200 4 Brian 7000





Page -1 of 1






Rpt 001 - Employee Master RunDate:08/03/2006
Parameter
Employee: ALL
Sal: ALL






deptid empid ename sal

300 4 Thomas 2000
300 5 Brian 7000





Page -1 of 1


Can some one help me in writing the script
# 2  
Old 08-24-2006
See the man page for awk. It should be able to cut out just the parts you want
- something like
$ cat yourfile | awk /"deptid empid ename sal"/,/"Page -"/ > tempfile
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[SOLVED] help clean up file movement script

Hello Group, Once again another script hacked together from a few sources to try and suit my needs. This is to go through a /temp directory and for each ls entry ask which Dir of three I want it sorted. The script works but there are a few behaviors that are odd so I figured I'd ask for help... (2 Replies)
Discussion started by: dpreviti
2 Replies

2. Emergency UNIX and Linux Support

Regular expression (regex) clean up text

Hi, Server - MEDIAWIKI - MYSQL - CENTOS 5 - PHP5 I have a database import of close to a million pages into my wiki, mediawiki site, the format that were left with is not pretty, and I need to find a way to clean this up and present it nicely... I think regex is the best option as I can... (1 Reply)
Discussion started by: lawstudent
1 Replies

3. UNIX for Advanced & Expert Users

Clean console output routed to a file

A friend routed some console output to a file for me. The problem is he used backspace and escape sequences all over the place. Using vi to view the file makes it difficult to read. Is there a program that will process the backspaces and remove the escape sequences? e.g., bash-3.00$ pwd^ (5 Replies)
Discussion started by: eddyq
5 Replies

4. Shell Programming and Scripting

clean passwd file based on db table (master)

The purpose of this script is to scan the /etc/passwd file one line at a time comparing the usernames to the usernames found in a database table. I will later locked every account which is not in the database table. I have export the userlist from the database in a file (/tmp/userlist). It... (1 Reply)
Discussion started by: Banks187
1 Replies

5. Shell Programming and Scripting

noob question - is awk the tool to clean dirty text files?

Hi, nevermind. I think I've found the answer. It appears I was looking for index, match, sub, and gsub. I want to write a shell script that will clean the html out of a bunch of files and format the data for import into excel. Awk seems like a powerful tool, but it seems oriented to... (1 Reply)
Discussion started by: yogert909
1 Replies

6. UNIX for Dummies Questions & Answers

command to clean up file systems

As you will verify, I am a really naive user of AIX 5.1. As such I wonder if you could possibly let me know of a command or procedure I could use to automatically, globally and safely, remove all useless files from my machine. I'm not referring to my own files because I perfectly know which of them... (1 Reply)
Discussion started by: ahjchr
1 Replies

7. UNIX for Advanced & Expert Users

Unable to clean up file system

Hi, Has anyone ever encountered the following scenario: I am working on a SUN server with solaris 10 installed and veritas managing the filesystem. One of the file systems has become full: df -kh /ossrc/dbdumps Filesystem size used avail capacity Mounted on... (6 Replies)
Discussion started by: eeidel
6 Replies

8. UNIX for Dummies Questions & Answers

Clean directories by reading from file

I have a file in following format directory1=/out/log purgedays1=4 extn1=log,out,txt directory2=/clean/log purgedays2=4 extn2=log,out now i need need to create a script that reads this file and cleans all the files with the given extn from the given directory. The catch here is that... (2 Replies)
Discussion started by: max_payne1234
2 Replies

9. UNIX for Advanced & Expert Users

Clean File

BeginDate 07/01/06 End: 07/31/06 Cust: A02991 - Burnham 0002000 5,829,773 145.3 0009701 4,043,850 267.3 2005000 286,785.13 100.0 BeginDate 07/01/06 End: 07/31/06 Cust: A01239 - East Track PSE Index A 0009902 317,356.82 890.2 0020021 ... (5 Replies)
Discussion started by: kris01752
5 Replies

10. Shell Programming and Scripting

Clean file in single action

What one finds challenging another finds simple... (HPUX B.11.11) I have a text file named something like 12345.dst that could look like this: DOG CAT NONE TEST CAT What I want to end up with is 12345.dst looking like this: CAT DOG TEST removing "NONE" should it be there and... (1 Reply)
Discussion started by: djp
1 Replies
Login or Register to Ask a Question