The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Yank a column in vi stevelrf UNIX for Dummies Questions & Answers 2 04-09-2006 03:04 AM
annoying vi yank word + delete all question umen UNIX for Dummies Questions & Answers 4 03-20-2006 08:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-27-2003
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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 (permalink)  
Old 01-27-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
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
criglerj criglerj is offline
Registered User
  
 

Join Date: May 2002
Location: Atlanta
Posts: 129
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
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
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 (permalink)  
Old 01-29-2003
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

BB 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 -4. The time now is 12:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0