yank


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers yank
# 1  
Old 01-27-2003
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 at this website ( http://www.unm.edu/~cs151/luger/references/vi.manual) after searching the forum to get an answer but it doesn't work for me ( :1,99g/^/''aco'a ) ?? What are they saying?

Gianni
# 2  
Old 01-27-2003
There isn't any great way to do this, but here what I do: I do a "yy" followed by a "p", then 8 dots. Then I move the cursor up and to a "10yy" Now each p will give me 10 lines. If that isn't enough I would just put 100 lines in the yank buffer. But 10 lines has always done it for me.
# 3  
Old 01-28-2003
The simplest way for this is to create your one line, then run it through an external filter. With the cursor on the same line, type

!!awk ' {for(i=0;i<100;i++) print'

If you find yourself doing this a lot, type the line into your buffer this way:

!!awk ' {for(i=0;i<100;i++) print'^V^M

i.e., append a carriage return to the line. Now go to the beginning of the line and type

"dD

Now "@d" will replace whatever line you're on with 100 copies of it.
# 4  
Old 01-28-2003
Thanks for the suggestion so far. Turns out the file I'll be working with is a huge file with 1 mil rows that I need to add 20 more columns to the end of each row. The columns to be added are all the same info. I tried experimenting with the paste command with a small file of 10 rows and it did exactly what I wanted. It appended the 10 columns to the end of each row of the first file and I thought I was smart. So I figured, okay, easiest way to add 20 more columns to this large file is to create a file with 1 mil rows of the additional columns to match the original file and then do the paste oldfile newfile > bigfile but when I couldn't duplicate the lines so easily and had to hit yy, it got to be annoying so I kind of wish I had been better at awk or something. If I want to avoid the yank case because there's no easy way to do it easily, then I may have to try criglerj solution huh?

Thanks, everyone.
# 5  
Old 01-28-2003
Quote:
Originally posted by giannicello
Thanks for the suggestion so far. Turns out the file I'll be working with is a huge file with 1 mil rows that I need to add 20 more columns to the end of each row. The columns to be added are all the same info.
Yikes! Your original post was talking about 100 to 1000 lines. If you want to add the same string of characters to each of 1 million lines in a file, don't use vi. Try this:

sed 's/$/<new string of stuff goes here>/' < input > output
# 6  
Old 01-29-2003
That was awesome! It did exactly what I wanted it to do.

Thanks. I was kind of hung up on finding a solution with paste but this is much better and quicker.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. 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

2. 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

3. UNIX for Dummies Questions & Answers

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 Replies)
Discussion started by: stevelrf
2 Replies

4. 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
Login or Register to Ask a Question