Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

add a fixed text to the beginning of every line

Posted on 2008-06-25
4
Medium Priority
?
343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 84

Assisted Solution

by:ozo
ozo earned 996 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 1004 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

636 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