views:

38

answers:

3

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

+2  A: 

One way to do this is to use awk.

awk '{ printf "svn+ssh://svn.xxx.com.jo"; print }' <filename>

If you want to modify the file in place, you can use sed with the -i switch.

sed -i -e 's_.*_svn+ssh://svn.xxx.com.jo&_' <filename>
Manoj Govindan
A: 
ruby -pne 'sub(/^/,"svn+ssh://svn.xxx.com.jo")' file
A: 

Simple way:

sed -i 's_._svn+ssh://svn.xxx.com.jo_' <filename>
hluk