Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scripting question with a text file 1

Status
Not open for further replies.

tjv

IS-IT--Management
Sep 19, 2001
100
US
I have a text file that gets generated each evening and I want to do 2 things to it.

1.) Remove the lines that say Page 1 of whatever and
2.) Remove the extra line feed from the file. example below.

Page 1 of 1
This is a test to see how to
remove these
extra line feeds.

In the example above I want to remove the Page 1 of 1 and the test to appear like so:

This is a test to see how to remove these extra line feeds.

can this be done. Any help would be extremely appreciated.

Thanks
 
The awk way:
Code:
awk '
/^Page/{next}{printf $0}END{printf "\n"}
' </path/to/inputfile

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Ok, that worked great. I have one last thing that needs to be done to the file.

In the file there are title heading all of which are capitalized. I would like to have a return after these words to make the document look alittle more fancy.

(ex) THIS IS THE HEADING now the text begins.

Would like it to be

THIS IS THE HEADING
now the text begins.

Is it also possible to read up to the next heading and put a return before the next heading as to separate the text like this.

THIS IS THE HEADING
now the text begins.

NEW HEADING HERE

Thanks again for any help.
 
Try something like this:
Code:
awk '
/^Page/{next}
{printf $0;if($0==toupper($0))printf &quot;\n&quot;}
END{printf &quot;\n&quot;}
' </path/to/inputfile

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top