Append to Stream Files
August 9, 2006 Hey, IT Jungle Forums
Is there an OS/400 command that will let me append one stream file to another? I checked the Copy Object (CPY) command, but it only has a REPLACE(*YES/*NO) parameter, unlike Copy File (CPYF), which supports MBROPT(*REPLACE/*ADD).
This question was posted on the IT Jungle Forums. It seems odd that there is no direct method using CL commands to append one stream file to another. Chris gave examples of two methods that do the job.
The first is to use Qshell’s >> redirection operator, which appends output to the destination file. Here’s how it would work in a CL program.
QSH CMD('cd /MyFolder && cat file1.txt >> file2.txt')
He also gave an example of using the FTP client.
FTP localhost userid pwd namefmt 1 append /myfolder/file1.txt /myfolder/file2.txt
In this case, both client and server are running on the iSeries. For localhost, try the word LOOPBACK. If that doesn’t work, try 127.0.0.1.
If you’d like to suggest another method, please add it to the thread at https://www.itjungle.com/itjforums/viewtopic.php?t=174.