1821204 Members
3311 Online
109631 Solutions
New Discussion юеВ

Re: tab delimited file

 
anthony dillard_1
Regular Advisor

tab delimited file

I have a script that query a database and list the ip addr mac addr and status of certian objects on one line, how do i make this file a tab delimited file. any help would be great
5 REPLIES 5
Court Campbell
Honored Contributor

Re: tab delimited file

usually you use a \t in your print statement.

in perl

# perl -e 'print "one\ttab\n"'

or using printf

# printf "two\t\ttabs\n"
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
anthony dillard_1
Regular Advisor

Re: tab delimited file

This is what i doing


SELECT n.ip_hostname, i.snmp_ifphysaddr, o.ip_status
FROM nnm_nodes n, nnm_interfaces i, nnm_objects o
WHERE i.node_id = o.ovw_id
AND o.topo_id = n.topo_id
ORDER BY n.ip_hostname, i.snmp_ifphysaddr;

then i run

/OV/opt/OV/bin/ovdwquery -file maccaddr > /tmp/hpstats/host2mac

to get the data, where would i put the t option
Dave Hutton
Honored Contributor

Re: tab delimited file

The man page for your command says
-t Write the output in TAB-separated format (default behavior).

So you should have to. I suppose you can try:
/OV/opt/OV/bin/ovdwquery -t -file maccaddr > /tmp/hpstats/host2mac

Re: tab delimited file

Assuming the fields in your output file are space seperated, you could use 'sed' to replace the spaces with tabs:

cat /tmp/hpstats/host2mac | sed 's/ / /g' > /tmp/hpstats/host2macV2

Within the 'sed' part, the space between the '/'s is literally a space character. The space between the second set of '/'s is a tab character. Therefore, when using this command line, make sure you hit the TAB key at this point.
anthony dillard_1
Regular Advisor

Re: tab delimited file

this is what i ended up doing

/OV/opt/OV/bin/ovdwquery -t -file maccaddr > /home/b009021/host2mac
sleep 5
grep cvt host2mac | egrep "2$|3$" > /tmp/cvt/macaddr
sleep 5
mv /tmp/cvt/macaddr /tmp/cvt/$(date +%Y)$(date +%m)$(date +%d).macaddr
sleep 10
/usr/bin/chown -R b06xob /tmp/cvt/*.macaddr