Print Part of an IFS File
July 23, 2008 Hey, Ted
Let’s say I have an IFS file with several thousand lines in it. Let’s say I want to print a few lines of that file. My current method is to copy the IFS file to another file, use Edit File (EDTF) with the copy to delete the lines I don’t want, and use EDTF’s Print command to get the report. Please tell me there’s an easier way. –Bob I recommend two Qshell commands. Sed, the stream editor, can select the lines you want to print. The Rfile utility can send them to a printer. Now, how do you want to select the lines? If you know the line numbers, you can use a command like this one: sed -n '93,96p' myfile.txt | rfile -wQ qsys/qsysprt This command prints lines 93 through 96 of file myfile.txt. If you want the system to select the lines based on the contents of the file, try something like this: sed -n '/WORLD/,/AMERICAN/p' myfile.txt | rfile -wQ qsys/qsysprt This example starts printing when it finds the string WORLD and stops printing after it finds a line with the string AMERICAN. Here’s another example that mixes the two record-selection methods: sed -n '/WORLD/,104p' myfile.txt | rfile -wQ qsys/qsysprt The system starts printing when it finds a line that contains WORLD, and stops printing after line 104. The Rfile utility allows Qshell to work with record-oriented files. I use it frequently to send Qshell output to a printer. Qshell commands are cryptic, but I find them very helpful when working with the IFS. –Ted RELATED STORY
|
That solved my immediate problem to add some debug output to my program, but be warned that every pipe to rfile creates another QP0ZSPWP job. Not only does the spool file not belong to the job that runs the QSH command (annoying) but you will also start filling up your job tables if not careful.