Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.xxx.com.jo/var/lib/svn/repos/b1me/products/payone/generic/code/core svn+ssh://svn.xxx.com.jo/var/lib/svn/repos/b1me/products/payone/generic/code/fees svn+ssh://svn.xxx.com.jo/var/lib/svn/repos/b1me/products/payone/generic/code/2ds

in other word i want to add "svn+ssh://svn.xxx.com.jo" 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://svn.xx.com.jo/var ... –  Iain Sep 22 '10 at 9:57

2 Answers 2

up vote 1 down vote accepted

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

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

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

share|improve this answer

Using sed:

sed 's|^|svn+ssh://svn.xxx.com.jo|' filename

To change the file in place:

sed -i 's|^|svn+ssh://svn.xxx.com.jo|' 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://svn.xxx.com.jo|' filename –  Dennis Williamson Sep 22 '10 at 10:10

Your Answer

 
discard

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.