- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Copy a line 10 times with vi in HP-UX
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 03:38 AM
тАО05-22-2003 03:38 AM
Copy a line 10 times with vi in HP-UX
I tried to yank a line using "yy" and tried to paste the same 10 times by using "10P". But the line got pasted only once.
In a similar way I tried to copy the line using "y$" and tried to paste it 10 times using "10P". This worked fine.
But in the second case, the line copied was pasted in the same line.
But I want this to happen in multiple lines.
Can any one suggest any other method other than using vi for duplicating a file containing one line 10 times.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 03:45 AM
тАО05-22-2003 03:45 AM
Re: Copy a line 10 times with vi in HP-UX
Try
yy
10pp
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 03:45 AM
тАО05-22-2003 03:45 AM
Re: Copy a line 10 times with vi in HP-UX
# awk '{for (i=0;i<10;i++) print $0}' infile > outfile
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 03:45 AM
тАО05-22-2003 03:45 AM
Re: Copy a line 10 times with vi in HP-UX
It is very easy if you run CDE.
Open the file with dtpad ,mark the line with left mouse button and copy with middle mouse button.
It is also possible to use this method with vi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 03:47 AM
тАО05-22-2003 03:47 AM
Re: Copy a line 10 times with vi in HP-UX
Try this:
line=$(cat file_with_line)
for i in 0 1 2 3 4 5 6 7 8 9
do
echo $line >>new_file
done
HTH, Vicente.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 03:48 AM
тАО05-22-2003 03:48 AM
Re: Copy a line 10 times with vi in HP-UX
[Position on Line]
Y P
2Y P
4Y P
2Y P
Makes 10 lines. I tend to use the simple approach for things like this,..
Y P P P P P P P P P
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 03:55 AM
тАО05-22-2003 03:55 AM
Re: Copy a line 10 times with vi in HP-UX
Paula, your solution did not work. It just prints the line 2 times as you mentioned pp.
James, Thanks a lot for that alternate suggesion. But can you also suggest me a solution by using vi. As none of the solution I recieved seems to work fine.
Leif, I don't wish to do a manual work for copying.
Regards!
Dipu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 04:21 AM
тАО05-22-2003 04:21 AM
Re: Copy a line 10 times with vi in HP-UX
Well, you asked for "..any other method other than using vi..." so I offered 'awk'.
In 'vi' do:
yy
p
.
...where the "." is a repetition of the 'p'ut, so you type "." eight times to yield a total of ten identical lines in the file. Simple and fast!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 04:48 AM
тАО05-22-2003 04:48 AM
Re: Copy a line 10 times with vi in HP-UX
Repeating . 10 times will do. But suppose I want to generalize to 1000 times it's difficult. So I want a direct method.
Your awk method really solved my problem. But out of curiosity I would like to know whether this is possible with vi.
Thanks a lot
Regards!!!
Dipu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 04:53 AM
тАО05-22-2003 04:53 AM
Re: Copy a line 10 times with vi in HP-UX
10yy
p
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 05:04 AM
тАО05-22-2003 05:04 AM
Re: Copy a line 10 times with vi in HP-UX
10yy
then move where you want to paste the lines.
p
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 05:16 AM
тАО05-22-2003 05:16 AM
Re: Copy a line 10 times with vi in HP-UX
Quite hard ... I can only do it using this command on the line to be duplicated :
!!awk '{while (i < 10) {print ; i++}}'
Only the first ! will be displayed and you will have 10 times the original line in you current file.
It can be put in a map (while Ypppppppppp can't)
:map v !!awk '{while (i < 10) {print ; i++}}'^M
hiting v in vi will duplicate 10 times current line.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 06:30 AM
тАО05-22-2003 06:30 AM
Re: Copy a line 10 times with vi in HP-UX
Paula's suggestion will work with vim.
I do most of the repeating stuff like what JRF has suggested second time.
I prefer to use vim than vi.
If you really want to automate the repetition n no. of times then awk is the best solution.
HTH
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2003 12:05 AM
тАО05-23-2003 12:05 AM
Re: Copy a line 10 times with vi in HP-UX
Most commands accept a preceding number as an argument, either to give a size or position (for display or movement commands), or as a repeat count (for commands that change text).
Looks like P and p are not in the list of "most commands". Too bad.
Not only that...
. Repeat the last command that changed the buffer. If a count is specified, the command is repeated the specified number of times.
But the following doesn't do that
Y
P
9.
The "9." just does it once!
Looks like we all learned something today.
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2003 02:01 AM
тАО05-23-2003 02:01 AM
Re: Copy a line 10 times with vi in HP-UX
yy
Got to the line where you want to place it and hit
p
And now (if you need 1000 times this line) 1000.
That's it
Roland
Feel free to assign points
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2003 06:48 AM
тАО05-23-2003 06:48 AM
Re: Copy a line 10 times with vi in HP-UX
Shift Double Quote
x
1000 yy
This will put 1000 lines into register x
Now go to where you want to copy
Shift Double Quote xp
For Shift Double
(Hold down the Shift Key, Hit the '" key)