Solved

add a fixed text to the beginning of every line

Posted on 2008-06-25
4
334 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
Comment Utility
perl -i.bak -pe "s/^/100" file
0
 

Author Comment

by:lucavilla
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
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

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…
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…
The viewer will learn how to count occurrences of each item in an array.
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 …

771 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

11 Experts available now in Live!

Get 1:1 Help Now