Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how i can add Add text at the beginning of each line?

for example:- i have file contain:- /var/lib/svn/repos/b1me/products/payone/generic/code/core /var/lib/svn/repos/b1me/products/payone/generic/code/fees /var/lib/svn/repos/b1me/products/payone/generic/code/2ds

i want it to become:-

svn+ssh:// svn+ssh:// svn+ssh://

in other word i want to add "svn+ssh://" at the beginning of each line of this file

share|improve this question
to get this to work you are going to have to add an svn command to the beginning of each line too e.g. svn list svn+ssh:// ... – Iain Sep 22 '10 at 9:57
up vote 1 down vote accepted

If your text is a file named "file.txt" you use this command line

awk '{print "svn+ssh://" $1}' file.txt

It will output what you want. (assuming that no path contain a space)

share|improve this answer

You can use Vim in Ex mode:

ex -sc '%s,^,svn+ssh://,|x' filename
  1. % select all lines

  2. s substitute

  3. x save and close

share|improve this answer

Using sed:

sed 's|^|svn+ssh://|' filename

To change the file in place:

sed -i 's|^|svn+ssh://|' filename
share|improve this answer
i execute it but the following error apear.....command garbled: – Mohammad AL-Rawabdeh Sep 22 '10 at 7:31
Your version of sed may need -e: sed -e 's|^|svn+ssh://|' filename – Dennis Williamson Sep 22 '10 at 10:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.