1.

Solve : vi to duplicate a specific column?

Answer»

I want to use vi [I know other ways outside of vi which can do what I want] to take column 3, and append it to the same line for SPECIFIC lines, eg., lines 20 thru 100: eg., abc xyz something => abc xyz something something

Here is an example of my file which contains the FOLLOWING lines:
...........
cp -p /dir/subdir/bnl/bnl.ear/webtop.war/file1
cp -p /dir/subdir/cdsa/cdsa.ear/webtop.war/custom/filea
cp -p /dir/subdir/wt1/contract.ear/webtop.war/custom/filex
cp -p /dir/subdir/dsa/dsa.ear/webtop.war/custom/file5
cp -p /dir/subdir/wt3/edmapp.ear/webtop.war/custom/filed
cp -p /dir/subdir/hr/hr.ear/webtop.war/custom/filez
cp -p /dir/subdir/wt2/offapp.ear/webtop.war/custom/fileggg
cp -p /dir/subdir/tfs/tfs.ear/webtop.war/custom/xyz
cp -p /dir/subdir/veto/veto.ear/webtop.war/custom/something
........
other lines that have some other garbage
........


I want to use vi to create a file LOOKING as follows:
........
cp -p /dir/subdir/bnl/bnl.ear/webtop.war/file1 /dir/subdir/bnl/bnl.ear/webtop.war/file1
cp -p /dir/subdir/cdsa/cdsa.ear/webtop.war/custom/filea /dir/subdir/cdsa/cdsa.ear/webtop.war/custom/filea
cp -p /dir/subdir/wt1/contract.ear/webtop.war/custom/filex /dir/subdir/wt1/contract.ear/webtop.war/custom/filex
cp -p /dir/subdir/dsa/dsa.ear/webtop.war/custom/file5 /dir/subdir/dsa/dsa.ear/webtop.war/custom/file5
cp -p /dir/subdir/wt3/edmapp.ear/webtop.war/custom/filed /dir/subdir/wt3/edmapp.ear/webtop.war/custom/filed
cp -p /dir/subdir/hr/hr.ear/webtop.war/custom/filez /dir/subdir/hr/hr.ear/webtop.war/custom/filez
cp -p /dir/subdir/wt2/offapp.ear/webtop.war/custom/fileggg /dir/subdir/wt2/offapp.ear/webtop.war/custom/fileggg
cp -p /dir/subdir/tfs/tfs.ear/webtop.war/custom/xyz /dir/subdir/tfs/tfs.ear/webtop.war/custom/xyz
cp -p /dir/subdir/veto/veto.ear/webtop.war/custom/something /dir/subdir/veto/veto.ear/webtop.war/custom/something
........
other lines that have some other garbage
........


I tried using the following: 20,100s/\(.*\) .*/& \3/
it just put the number 3 after the DESIGNATED lines. Any idea what is wrong?

THANKS in advance....



Discussion

No Comment Found