Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting tabs size/column width e.g df -k >disk_usage_report

Status
Not open for further replies.

sjsp

Technical User
Aug 24, 2001
14
GB
Hi,

I am writing a script to run 'df -k' on remote machines and redirecting the output to a file.

This works fine but the problem I have it that as the tab length is 8 characters, anything larger than 8 chars is shifted right. Is there anything I can do to rectify this?

An extract/example from the scripts is as follows:

remsh $host df -lk | awk '{print $2 "\t\t" $3 "\t\t" $4 "\t\t" $5 "\t\t" $6}'> disk-usage-from-$host

I.E the columns displayed are:

kbytes used avail capacity Mounted

If the result outputs that the kbytes is greater that 8 chars the rest of the line shifts to the right and the columns do not appear in alignment with the smaller filesystems.

I have has a look at the tabs command etc
 
No need to cross-post on the Unix forums ... they're all quite busy :)

As I said in the other reply, use printf instead of print in your awk command. Then you can format the output as you like.

Greg.
 
Thanks Greg


For both tips : )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top