- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Some vi help please ...
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
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
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
01-22-2003 02:10 PM
01-22-2003 02:10 PM
vi +"1,15w! newscript|q" originalscript
This works like a charm, but what if I now wanted to yank some more line from "originalscript" and write them to "newscript"? Thus far it would overwrite newscript, not append like I would want it to. Any ideas my great HP Masterguru Shell Progammers and Perl Magicians? Can I do a merge or something like that?
Thank you, Andy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2003 02:19 PM
01-22-2003 02:19 PM
Re: Some vi help please ...
The alternative, of course, is to yank the later lines to a third file, and then simply cat the third file with an "append redirect" (>>) to the target file. If desired, this could all happen in one command line, using semicolons to seperate command sequences.
If you are doing this in a script, however, you could also use variables to hold the yanked lines or the file they went to, and then append them or manipulate them as desired.
As in all UN*X stuff, there are a dozen ways to do anything, six of which are acceptable to most people, and a couple of which are optimal. Maybe somebody else will suggest a more 'optimal' approach...
Best Regards, and good luck with it. --bmr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2003 02:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2003 12:18 AM
01-23-2003 12:18 AM
Re: Some vi help please ...
You should look at sed, or awk, or perl, or ...
My preference is awk. To copy lines 15 through 30 inclusive from file1 and append to file2, something like:
cat file1|awk '(NR >=15 && NR <=30) {print} ' >> file2
- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2003 12:19 AM
01-23-2003 12:19 AM
Re: Some vi help please ...
It's about the second perl call, the first is only to generate a list to prove it works:
a5:/u/usr/merijn 102 > perl -le 'print for 1..10'
1
2
3
4
5
6
7
8
9
10
a5:/u/usr/merijn 103 > perl -le 'print for 1..60' | perl -ne'(10..15 or 20..22 or 30..32)and print'
10
11
12
13
14
15
20
21
22
30
31
32
a5:/u/usr/merijn 104 >
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2003 04:59 AM
01-23-2003 04:59 AM
Re: Some vi help please ...
Merijin, could you give me an example on how I would use the perl example but reference an actual file to print these lines from. I can duplicate what you are doing, but where in the command would I actually reference my file to get these lines from? I'm very new to perl.
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2003 08:16 AM
01-23-2003 08:16 AM
Re: Some vi help please ...
a5:/u/usr/merijn 103 > perl -ne'(10..15 or 20..22 or 30..32)and print' your_file
note that since this not so widely known feature uses line ranges, you have to make a single line a range too (e.g. 14..14)
Enjoy, have FUN! H.Merijn