remove columns using vi


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers remove columns using vi
# 1  
Old 08-24-2010
remove columns using vi

Hi,

I have a csv file, contents are shown below:
Code:
abcd,efgh,ijkl,mnop,qrst
ksajdjksah,askdasj,askhdakjs,sadjkhas
iqwdym,sadkj,asdkjha,sadhkjas,sadlkj
sakjhdkjas,sadkhask,sadkhjasd,asdkhj

How would I be able to remove the first 3 columns (csv file) from the file using vi or any other unix command.

Thanks,
Muthu

Last edited by radoulov; 08-24-2010 at 06:34 AM.. Reason: Added code tags!
# 2  
Old 08-24-2010
In command mode:

Code:
:%s/\([^,]*,[^,]*,[^,]*,\)//

With vim (or other vi clone that supports re-interval:

Code:
:%s/\([^,]*,\)\{3}//

Otherwise:

Code:
cut -d, -f4- infile

This User Gave Thanks to radoulov For This Post:
# 3  
Old 08-24-2010
Thanks a ton !!!

Thanks a lot for the quick reply.

The cut command on the command line seems to be a easier one.

Thanks again,
Muthu
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to remove last two columns

I am writing an awk script to remove the last two fields in a pipe delimited file. The script that I have currently deletes the last two fields but each field is being printed on its own line in the output. I can't seem to get the rows to print out on the same line as the input data. This is what I... (4 Replies)
Discussion started by: chamuco666
4 Replies

2. Shell Programming and Scripting

Remove nullable columns in lines

Hi Every one, my requirement is to remove the null columns in line, comma delimiter used For example, A,11,20,30,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, B1,,,,,, gem,plum,kite,,,,gud,bad,,,,,,,,,,,,, B2,kiing,kong,height,,,,,,,,,,,,,,,,,,,,,,,,,rak,,,,,,,,,,,,, B1,,,,,,... (9 Replies)
Discussion started by: skpshell
9 Replies

3. Shell Programming and Scripting

Remove first n characters from specific columns

I have a file like: s_20331 803 1 1 5 1:2=0.00000000 1:3=0.00000000 1:4=0.11111111 s_20331 814 1 1 5 1:2=0.00000000 1:3=0.12611607 1:4=0.00000000I would like to remove the four characters "x:x=" from all columns containing them (in my actual file, there are 15 total columns (i.e. columns... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

4. Shell Programming and Scripting

Remove Duplicate by considering multiple columns

hi friends, my input chr1 exon 35204 35266 gene_id "GOLGB1"; transcript_id "GOLGB1"; chr1 exon 42357 42473 gene_id "GOLGB1"; transcript_id "GOLGB1"; chr1 exon 45261 45404 gene_id "GOLGB1"; transcript_id "GOLGB1"; chr1 exon 50701 50778 gene_id "GOLGB1"; transcript_id "GOLGB1";... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

5. UNIX for Dummies Questions & Answers

help needed: remove space between certain columns

dear all, i have a data looks like this (i have 3000 columns): rs123 A T T G C C C C C C A A A A A A A A A A A ... rs154 T T G C C C C C A A A A A A A A A A T T G ... rs126 A C C C C C A A A A A A A A A A A A T T G ... I want to remove all the space after the 2nd column and make the... (2 Replies)
Discussion started by: forevertl
2 Replies

6. Shell Programming and Scripting

Single command for add 2 columns and remove 2 columns in unix/performance tuning

Hi all, I have created a script which adding two columns and removing two columns for all files. Filename: Cust_information_1200_201010.txt Source Data: "1","Cust information","123","106001","street","1-203 high street" "1","Cust information","124","105001","street","1-203 high street" ... (0 Replies)
Discussion started by: onesuri
0 Replies

7. UNIX for Dummies Questions & Answers

How to remove columns with specific string?

If I have a data test.txt with 1000 columns such as: id sex gene1 gene2 gene2.dl gene3 gene4 gene4.dl ....... 1 1 AA AT AT TT AT AT ....... 2 1 AG TT TT TA AA AA ....... 3 2 AA AT AT TT AT ... (2 Replies)
Discussion started by: AMBER
2 Replies

8. Shell Programming and Scripting

remove duplicated columns

hi all, i have a file contain multicolumns, this file is sorted by col2 and col3. i want to remove the duplicated columns if the col2 and col3 are the same in another line. example fileA AA BB CC DD CC XX CC DD BB CC ZZ FF DD FF HH HH the output is AA BB CC DD BB CC ZZ FF... (6 Replies)
Discussion started by: kamel.seg
6 Replies

9. Shell Programming and Scripting

Remove spaces from columns

I have a file with only one field something like this : 213.45 220.65 240.47 345.67 320.45 I want to remove all spaces in between. Is there any unix command for that ?Thanks in advance.. (2 Replies)
Discussion started by: jacks
2 Replies

10. Shell Programming and Scripting

Remove lines with n columns

Hi folks - hope you are all well. I am trying to perform some pre-processing on a data file, to make sure it is in a valid format before performing a data upload. Each row of data in the file should consist of 10 comma delimited fields. Can anyone advise me of a sed/awk command that might... (2 Replies)
Discussion started by: Krispy
2 Replies
Login or Register to Ask a Question