Solved

File editing script

Posted on 2014-03-17
1
146 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MySQL Web Database 5 105
Port 80 requests 16 80
Perl Scripting from a shell script with if and for 4 82
Awk Question 2 116
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

13 Experts available now in Live!

Get 1:1 Help Now