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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Script to Loop through Files 1

Status
Not open for further replies.

erock24

Technical User
Aug 14, 2009
4
US
I'm looking for a Perl script that will loop through all .lod files in the folder the script resides, open the file, find and delette all instances of the word "tabular", save and close.

I appreciate any help.
Thank you very much for your time.

 
I think it's probably unlikely that you will find a script with that exact specification. You may even have to write one yourself. If you do go down this route, we can cetrainly help you with any problems you may encounter. Post your code, and we'll have a look at it...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Code:
perl -pi'.bak' -e 's/tabular//g' *.lod

Once you're happy you can delete the backup files (*.bak)

HTH


Trojan.
 
Probably slightly safer to use word boundaries too.
Code:
perl -pi'.bak' -e 's/\btabular\b//g' *.lod
 
YAY Ishnid!
Good to see you again.

And yes, I absolutely agree with the word boundaries.

:)



Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top