Removing columns of a file using vi Editor


 
Thread Tools Search this Thread
# 1  
Removing columns of a file using vi Editor

Hi Experts,

I have a file which looks like in this way
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
# 2  
Quote:
Originally Posted by DilipPanda
Hi Experts,

I have a file which looks like in this way
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
In your vi editor issue the following
Code:
:%s/^[^ ]* //g

# 3  
if columns are '|' separated:
Code:
:%s/^[^|]*|//


Last edited by vgersh99; 02-08-2008 at 07:15 AM..
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #823
Difficulty: Medium
The HTML 5 syntax is based on SGML.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing duplicates from delimited file based on 2 columns

Hi guys,Got a bit of a bind I'm in. I'm looking to remove duplicates from a pipe delimited file, but do so based on 2 columns. Sounds easy enough, but here's the kicker... Column #1 is a simple ID, which is used to identify the duplicate. Once dups are identified, I need to only keep the one... (2 Replies)
Discussion started by: kevinprood
2 Replies

2. Shell Programming and Scripting

Removing duplicates in fixed width file which has multiple key columns

Hi All , I have a requirement where I need to remove duplicates from a fixed width file which has multiple key columns .Also , need to capture the duplicate records into another file . File has 8 columns. Key columns are col1 and col2. Col1 has the length of 8 col 2 has the length of 3. ... (5 Replies)
Discussion started by: saj
5 Replies

3. UNIX for Dummies Questions & Answers

Removing 2nd Column in Vi Editor

I have text like this M83-306 132 797 M83-312 145 685 M83-315 321 479 M83-319 654 193 M83-350 556 1184 M83-303 222 199 and I want to make it like this M83-306 797 M83-312 685 M83-315 ... (9 Replies)
Discussion started by: muhnandap
9 Replies

4. UNIX for Dummies Questions & Answers

Removing columns from a text file that do not have any values in second and third columns

I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns: 4 0.04972604 KLHL28 4 0.0497332 CSTB 4 0.04979822 AIF1 4 0.04983331 DECR2 4 0.04990344 KATNB1 4 4 4 4 How can I remove the trailing... (3 Replies)
Discussion started by: evelibertine
3 Replies

5. Shell Programming and Scripting

Removing columns using awk

HI , I have a comma delimiter file, in which I want to remove 8th and 9th column. I tried removing those columns using the below code awk 'BEGIN { FS=","; OFS="," } {$8=$9="";gsub(",+",",",$0)}1' infile But the problem is 8th and 9th columns are user entered fields, theyvhave carriage... (1 Reply)
Discussion started by: mora
1 Replies

6. Shell Programming and Scripting

Removing columns using awk

HI , I want to remove 5th and 6th column from a .csv file using awk.is there any way of this apart from writing the each field as below awk -F, '{print $1,$2,$3,$7......$100}' OFS=, infile. Thx, Deepti (4 Replies)
Discussion started by: gaur.deepti
4 Replies

7. Shell Programming and Scripting

Removing columns from awk '{ print $0 }'

I have a one-line command, lsusb | awk '{ $1=""; $2=""; $3=""; $4=""; $5=""; $6=""; print $0 }' It works, and gives the results I expect, I was just wondering if I am missing some easier way to nullify the first 6 column variables? Something like, lsusb | awk '{ $(1-6)=""; print $0 }' But... (10 Replies)
Discussion started by: AlphaLexman
10 Replies

8. Shell Programming and Scripting

Removing columns with dashes

My files look like this I need to remove the columns where dashes are the majority, if any of the sequences has any character in that particular position it should be removed too. The IDs and Freqs should be kept intact. Thus, the resulting file should look like this Thanks in advance (14 Replies)
Discussion started by: Xterra
14 Replies

9. Shell Programming and Scripting

Removing blank columns from a file

Hi, I have a sample file as shown below -- id parent name dba -----------------------------------... (7 Replies)
Discussion started by: sumirmehta
7 Replies

10. HP-UX

How to add space in between columns in VI editor

Hi, I am trying to add space after 3rd and 6th column for editing a file in special format. How should I achieve in VI?. So, is it possible to do in it in sed ? thanks vipa (1 Reply)
Discussion started by: vipas
1 Replies

Featured Tech Videos