Solved

add a fixed text to the beginning of every line

Posted on 2008-06-25
4
336 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
echo paypal data on screen 5 54
applying error reporting code to see paypal error messages 13 61
PHP Query return divisible by 3 3 18
How do I fix this UPDATE error? 7 24
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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

832 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