parsing out from rpm -qa --queryformat into CSV output
I found several different web sites talking about this but my problem is slightly different and I haven't been able to find an answer anywhere. When querying the RPM database usin TAGS like
rpm -qa --qf '%{NAME} %{VERSION}.%{RELEASE} %{SUMMARY} %{VENDOR} %{DESCRIPTION} %{INSTALLTIME:date}\n' I get tabbed output I am looking for except the output from the DESCRIPTION tag contains LF characters so when importing it into an excel spreadsheet, every line from the DESCRIPTION tags causes a new line. I'm looking for the the ability to run the above RPM command and have the output from each of the TAGS separated by tabs with no cr or lf so they will correctly import into a spreadsheet where each TAG has it's own column. I've tried using tr to change \n to a space (|tr '\n' ' ') but then all of the output is one continuous line. I think I'm close but just can't quite see it. Thoughts? |
Quote:
You might be more successful by putting double quotes around the %{DESCRIPTION}, hoping that there are no double quotes inside the %{DESCRIPTION}. Should be feasible with a pipeline of sed commands - first convert double quotes to something else, then add them around the description. |
The output from each TAG (NAME,VERSION,SUMMARY etc) is currently separated by a tab and has no lf in the output. The DESCRIPTION output, because it can be longer,does have lf in the output so when attempting to input it into Excel or similar, the DESCRIPTION output ends up taking up multiple cells instead of just using one cell in the spreadsheet like all of the other TAGS. I'd like to be able to strip the lf from the DESCRIPTION output only. That way all of the TAGS would be on one line but separated by TABS so they would successfully import into Excel. I will play around with SED and see what I can come up with.
Quote:
Quote:
|
If you got rid of the DESCRIPTION and only used the SUMMARY (why both anyway), you might find the problem goes away.
I had a play using awk, but it could get ugly. |
Removing the DESCRIPTION TAG definitely removes the problem as it's the only output with lf in it. I was just keeping the DESCRIPTION tag because it provides a lot more detail.
Quote:
|
All times are GMT -5. The time now is 08:32 PM. |