Removing columns of a file using vi Editor

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dilip1983
    New Member
    • Jan 2008
    • 21

    Removing columns of a file using vi Editor

    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
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    Originally posted by Dilip1983
    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"

    Comment

    • Dilip1983
      New Member
      • Jan 2008
      • 21

      #3
      Originally posted by ashitpro
      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

      Comment

      • ashitpro
        Recognized Expert Contributor
        • Aug 2007
        • 542

        #4
        Originally posted by Dilip1983
        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.

        Comment

        • WinblowsME
          New Member
          • Jan 2008
          • 58

          #5
          This should remove the line numbers.

          Code:
          :%s/^[0-9]* //

          Comment

          Working...