Yank a column in vi


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Yank a column in vi
# 1  
Old 04-08-2006
Yank a column in vi

I have a file which has data in columns.
Is there a way to yank columns in vi?
I tried searching in this forum. I did not find it.
Please help me out.
# 2  
Old 04-08-2006
Most versions of vi support the C-x commands.

Try man vi and look for open-rectangle, clear-rectangle, yank-rectangle,
delete-rectangle

If you have a big file and you want to lose,say all of column #5 in the entire file, try awk, it's a lot easier.
Code:
awk ' { print $1, $2, $3 , $5, $6}' oldfile>newfile

# 3  
Old 04-09-2006
Thanks for the info. I know that this can be done with awk. I wanted to know if there is a way via VI itself.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

2. Shell Programming and Scripting

Difference of the same column when two other column matches and one column differs less than 1 hour

This is my input file : # cat list 20130430121600, cucm, location,76,2 20130430121600,cucm1,location1,76,4 20130430122000,cucm,location,80,8 20130430122000,cucm1,location1,90,8 20130430140000,cucm1,location1,87,11 20130430140000, cucm,location,67,9 This is the required output ... (1 Reply)
Discussion started by: Lakshmikumari
1 Replies

3. UNIX for Dummies Questions & Answers

Rename a header column by adding another column entry to the header column name

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (1 Reply)
Discussion started by: Vavad
1 Replies

4. Shell Programming and Scripting

Rename a header column by adding another column entry to the header column name URGENT!!

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (4 Replies)
Discussion started by: Vavad
4 Replies

5. UNIX for Dummies Questions & Answers

Yank versus control-insert formatting differences?

Hello! Graduate student thrown to the sharks of unix and fortran77 here. My basic question is this: what exactly is the difference between yank (ie "*yG for the whole file and "*p in a new file) and control-insert / shift-insert with respect to text formatting? One is vi and one is Windows,... (2 Replies)
Discussion started by: marshlight
2 Replies

6. Shell Programming and Scripting

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 file 1 sample SNDK 80004C101 AT XLNX 983919101 BB NETL 64118B100 BS AMD 007903107 CC KLAC 482480100 DC TER 880770102 KATS ATHR 04743P108 KATS... (7 Replies)
Discussion started by: rydz00
7 Replies

7. Shell Programming and Scripting

^M in yank but not in file in Vim

I am trying to visually select a section of text in vim and then substitute for it using the :%s/ sequence. First I visually select text. Then I yank using "ay. Then I type :%s/ followed by Control R and the register name, in this case a. This fills in the text I have visually selected into... (6 Replies)
Discussion started by: Enobarbus37
6 Replies

8. Shell Programming and Scripting

Changing one column of delimited file column to fixed width column

Hi, Iam new to unix. I have one input file . Input file : ID1~Name1~Place1 ID2~Name2~Place2 ID3~Name3~Place3 I need output such that only first column should change to fixed width column of 15 characters of length. Output File: ID1<<12 spaces>>Name1~Place1 ID2<<12... (5 Replies)
Discussion started by: manneni prakash
5 Replies

9. UNIX for Dummies Questions & Answers

annoying vi yank word + delete all question

Hello when i try to yank word only that looks like this "$$foo$" when i stand with my curser marker on the first char ($) and do in vi : "yw" (yank word) its yanks me only the "$" char when i stand white my curser on "f" its yank's me only "foo" how can i yank all word no matter what... (4 Replies)
Discussion started by: umen
4 Replies

10. UNIX for Dummies Questions & Answers

yank

This is supposed to be simple to do but I am having a hard time trying to yank 1 line (yy) but creating from it 100 lines. I can do yy then keep hitting . to repeat but it doesn't make sense. I may want to create 1000 lines from the one liner. yy then 99 p doesn't work.... Thanks. I was... (5 Replies)
Discussion started by: giannicello
5 Replies
Login or Register to Ask a Question