- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Joining two files in rexx
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
06-25-2007 02:54 AM
06-25-2007 02:54 AM
Joining two files in rexx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2007 03:05 AM
06-25-2007 03:05 AM
Re: Joining two files in rexx
Windows, either. Are you in the right forum?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2007 04:32 AM
06-25-2007 04:32 AM
Re: Joining two files in rexx
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2007 06:12 AM
06-25-2007 06:12 AM
Re: Joining two files in rexx
You are probably submitting this question to the wrong forum. Please elaborate as to what rexx might stand for. What platform, what tool, and if you care about a solution, what specific join requirements (sort order, duplicates,...).
Is this pertaining a windows style ini file a per:
http://cwashington.netreach.net/depo/view.asp?Index=525&ScriptType=rexx
If so, I suspect your best bet is to simply use an editor to manually merge.
If I were to write a script to do this then I woudl use perl and exploit 'Hash of Arrays' to name each group and add line to those group. I don't know what you should do with dups (retain first, last, both?)
See for example: http://www.ayni.com/perldoc/perl5.8.0/pod/perldsc.html
Sample perl solution:
------------------------ test.pl ---------
while ($file = shift) {
open FILE, "<$file" or die "Could not open file $file";
$key = " ";
push @{ $HoA{$key} }, "\n/* Entries from $file */\n";
while (
if (/^\[\w+\]$/) {
$key = $_;
push @{ $HoA{$key} }, "\n/* Entries from $file */\n";
} else {
push @{ $HoA{$key} }, $_;
}
}
}
foreach $key (sort keys %HoA) {
print "$key\n", join ("", @{$HoA{$key}}), "\n";
}
----------
Sample usage
perl test.pl map2.ini map3.ini > map1.ini
The above script adds traces to show whre sections came from. Without that it could read:
------------------------ test.pl ----------
while ($file = shift) {
open FILE, "<$file" or die "Could not open file $file";
$key = " ";
while (
if (/^\[\w+\]$/) {
$key = $_;
} else {
push @{ $HoA{$key} }, $_;
}
}
}
foreach $key (sort keys %HoA) {
print "$key", @{$HoA{$key}};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2008 08:44 AM
09-19-2008 08:44 AM
Re: Joining two files in rexx
Which version of REXX are you using. Code will very by version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2008 08:54 AM
09-19-2008 08:54 AM
Re: Joining two files in rexx
A sample in OO-REXX would be:
files = "file1 file2"; z=0
do n=1 to words(files)
curfil = word(files,n)
rc = SysFileTree(curfil, 'inpfil', 'FO')
if rc = 0 & inpfil.0 > 0 then do xx = 1 to inpfil.0
ReadFile = .stream~new(inpfil.xx)
ReadFile~open("READ")
do while ReadFile~lines() > 0
z = z + 1
oline.z = strip(ReadFile~linein)
end /* end do do while */
ReadFile~close
end /* end if rc=0 */
end /* end do n=1 */
WFile = .stream~new(outfil)
WFile~open("WRITE")
do y =1 to z
WFile~lineout(oline.y,y)
end /* end do n= */
WFile~close
If you are on mainframe "linein" and "lineout" still work, but syntax is diff and you have to load the file via "EXECIO" on some systems.