Solved

add a fixed text to the beginning of every line

Posted on 2008-06-25
4
335 Views
Last Modified: 2013-12-13
I have a file like this:

yellow
brown
red

How do I add with Perl or PHP (command-line in Windows) - with the fastest execution time - the fixed text "100" to the beginning of every line, obtaining the following?

100yellow
100brown
100red
0
Comment
Question by:lucavilla
  • 2
4 Comments
 
LVL 84

Assisted Solution

by:ozo
ozo earned 249 total points
ID: 21868339
perl -i.bak -pe "s/^/100" file
0
 

Author Comment

by:lucavilla
ID: 21869485
ozo, I get this error:

c:\Perl\bin\perl -i.bak -pe "s/^/100" input.txt
Substitution replacement not terminated at -e line 1.
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 251 total points
ID: 21869948
There is a missing / at the end.  It should be:
    c:\Perl\bin\perl -i.bak -pe "s/^/100/" input.txt
0
 

Author Closing Comment

by:lucavilla
ID: 31470690
Thanks!
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
Sort Multidimensional Array 11 34
php date - compare 4 40
test if query has no results 2 19
updating the date data 12 20
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

914 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

16 Experts available now in Live!

Get 1:1 Help Now