× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.





db2 "select agtbra || ',' || char(agtnoa) || ',' || agtnaa from
anvdev.agtmas" | sed -n '/,/p'  > /mxp/mxpsql.csv

The QSHELL manual didn't provide me with any clues.

Here's the page in the Information Center that describes the "sed" utility:
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/topic/rzahz/sed.htm

Here's what it says about -n:

  -n   By default, each line of input is echoed to the standard output
       after all of the commands have been applied to it. The -n option
       suppresses this behavior.

Here's what it says about p:

[2addr]p
    Write the pattern space to standard output.

So... the command line "sed -n '/,/p'" would print only the lines that have commas in them. The -n suppresses printing of the other lines, the /,/ tells it to search for a comma, ands the p tells it to print matching lines.

To see why this is needed, try running the command without the "sed" in it. You'll see that it outputs some text at the start and end of the query, but none of that text contains a comma. Basically, by stripping every line that doesn't contain a comma, you've deleted those extra lines of output.

The quotes around /,/ aren't really necessary, since neither / nor , is a special character. If you like, you can just code sed -n /,/ (the same thing, but without the single quotes)

Good luck


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.