Solved

File editing script

Posted on 2014-03-17
1
147 Views
Last Modified: 2014-04-12
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
Comment
Question by:Rothbard
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39935785
find directory -type f -print0 | xargs -0 perl -i.bak -pe 's#(?!^)//#///<#g; s#^//#///#'
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
perl to display a matrix report for 3-dimenional array 3 64
transpose into pipe delemited 8 67
perl to convert excel to csv 3 182
what are these modules in perl script 4 94
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now