The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Yank a column in vi stevelrf UNIX for Dummies Questions & Answers 2 04-08-2006 11:04 PM
annoying vi yank word + delete all question umen UNIX for Dummies Questions & Answers 4 03-20-2006 04:46 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-2003
Registered User
 

Join Date: Sep 2001
Location: Phoenix
Posts: 76
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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
Forum Sponsor
  #2 (permalink)  
Old 01-27-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,205
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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 (permalink)  
Old 01-28-2003
criglerj's Avatar
Registered User
 

Join Date: May 2002
Location: Atlanta
Posts: 129
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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 (permalink)  
Old 01-28-2003
Registered User
 

Join Date: Sep 2001
Location: Phoenix
Posts: 76
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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 (permalink)  
Old 01-28-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,205
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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
Google UNIX.COM
Closed Thread



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 08:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102