• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

File editing script

I need a program which makes the following changes to all the files in a directory and its subdirectories:

- replace "//" with "///", if the "//" is at the beginning of a line
- replace "//" with "///<" if the "//" is not at the beginning of a line.

I would be very grateful for any help.
0
Rothbard
Asked:
Rothbard
1 Solution
 
ozoCommented:
find directory -type f -print0 | xargs -0 perl -i.bak -pe 's#(?!^)//#///<#g; s#^//#///#'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now