![]() |
|
|
|||||||
| 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 |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 | ||
|
|
|
||||
|
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. |
|
|||
|
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. |
|
||||
|
Quote:
sed 's/$/<new string of stuff goes here>/' < input > output |
||||
| Google UNIX.COM |