1757325 Members
2518 Online
108860 Solutions
New Discussion юеВ

simple vi question

 
SOLVED
Go to solution
someone_4
Honored Contributor

simple vi question

Hey everyone i have a simple vi question here.

I have a file like this but instead of like 10 lines i have like 150.

1
2
3
4
5
5
6
7
8
9
10

And I want it to look like this:

1 ok
2 ok
3 ok
4 ok
5 ok
6 ok
7 ok
8 ok
9 ok
10 ok

I want an ok next to the number.

Thanks
Richard

3 REPLIES 3
harry d brown jr
Honored Contributor
Solution

Re: simple vi question

:s/$/ ok/g99999


live free or die
harry
Live Free or Die
Thierry Poels_1
Honored Contributor

Re: simple vi question

Hi,

:%s/$/ OK/ if the number is everything on the line.

:%s/^[0-9]*/& OK / if there is more text after the number.

good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Sanjay_6
Honored Contributor

Re: simple vi question

Hi Richard,

Use
vi file_name

esc --> :

:1,$ s/$/ ok/gp

Save file and exit. this will add " ok" at the end of each line.

hope this helps.

Regds