By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,773 Members | 911 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,773 IT Pros & Developers. It's quick & easy.

Removing columns of a file using vi Editor

P: 21
Hi Gurus,

The data in the file looks like in this format
1 2233|A.K Shukla |G.M |Sales |12/12/52|6000
2 9876|Jai Sharma |Director |Production |12/03/50|67000
3 5678|Sumit Chakarborty |D.G.M |Marketing |19/04/43|6000
4 2365|Barun Sengupta |Director |Personnel |11/05/47|7800
5 5423|N.K. Gupta |Chairman |Admin |30/08/56|5400
6 1006|Chanchal Singhvi |Director |Sales |03/09/38|67000
7 6213|Karuna Ganguly |G.M |Accounts |05/06/62|6300
8 1265|S.N. Sengupta |Manager |Sales |12/09/63|5600
9 4290|Jayant Choudhury |Executive |Production |07/09/50|6000
10 2476|Anil Aggarwal |Manager |Sales |01/05/59|5000
11 6521|Lalit Choudhuwdury |Director |Marketing |26/09/45|8200
12 3212|Shyam Saksena |D.G.M |Accounts |12/12/55|6000
13 3564|Sudhir Agarwal |Executive |Personnel |06/07/47|7500
14 2345|J.B Saxena |G.M |Marketing |12/03/45|8000
15 0110|V.K Agrawal |G.M |Marketing |31/12/40|8900

I want to delete the 1st column using vi Editor.

How can i do that?

Kindly suggest me.

Thanks in Advance.
Dilip
Feb 8 '08 #1
Share this Question
Share on Google+
4 Replies

ashitpro
Expert 100+
P: 542
Hi Gurus,

The data in the file looks like in this format
1 2233|A.K Shukla |G.M |Sales |12/12/52|6000
2 9876|Jai Sharma |Director |Production |12/03/50|67000
3 5678|Sumit Chakarborty |D.G.M |Marketing |19/04/43|6000
4 2365|Barun Sengupta |Director |Personnel |11/05/47|7800
5 5423|N.K. Gupta |Chairman |Admin |30/08/56|5400
6 1006|Chanchal Singhvi |Director |Sales |03/09/38|67000
7 6213|Karuna Ganguly |G.M |Accounts |05/06/62|6300
8 1265|S.N. Sengupta |Manager |Sales |12/09/63|5600
9 4290|Jayant Choudhury |Executive |Production |07/09/50|6000
10 2476|Anil Aggarwal |Manager |Sales |01/05/59|5000
11 6521|Lalit Choudhuwdury |Director |Marketing |26/09/45|8200
12 3212|Shyam Saksena |D.G.M |Accounts |12/12/55|6000
13 3564|Sudhir Agarwal |Executive |Personnel |06/07/47|7500
14 2345|J.B Saxena |G.M |Marketing |12/03/45|8000
15 0110|V.K Agrawal |G.M |Marketing |31/12/40|8900

I want to delete the 1st column using vi Editor.

How can i do that?

Kindly suggest me.

Thanks in Advance.
Dilip


So you want to remove line numbers?
I don't know whether that line numbers are the part of your text or it is assigned by vi editor.
any way..we have solutions for both

case 1: If line numbers(in your case) are part of your text.
press the ESC(i.e goto escape mode)
press cntrl + v (i.e ctrl key and v key together)
navigate through arrow keys.
one you finishes your selection. press 'dd'

case 2:If line numbers are given by vi editor
press ESC
press : (i.e colon)
type "set nonu"
Feb 8 '08 #2

P: 21
So you want to remove line numbers?
I don't know whether that line numbers are the part of your text or it is assigned by vi editor.
any way..we have solutions for both

case 1: If line numbers(in your case) are part of your text.
press the ESC(i.e goto escape mode)
press cntrl + v (i.e ctrl key and v key together)
navigate through arrow keys.
one you finishes your selection. press 'dd'

case 2:If line numbers are given by vi editor
press ESC
press : (i.e colon)
type "set nonu"
I am sorry but the command given by u is not working.
My case is 1st one. Can u suggest any other way.

Thanks
Dilip
Feb 8 '08 #3

ashitpro
Expert 100+
P: 542
I am sorry but the command given by u is not working.
My case is 1st one. Can u suggest any other way.

Thanks
Dilip
well,
try opening your file with 'vim' command instead 'vi',and try above things again.
Better you tell me OS you are using.
Feb 8 '08 #4

P: 58
This should remove the line numbers.

Expand|Select|Wrap|Line Numbers
  1. :%s/^[0-9]* //
Feb 8 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.