df output is not aligned.


 
Thread Tools Search this Thread
Operating Systems AIX df output is not aligned.
# 1  
Old 07-06-2005
df output is not aligned.


When I issue a "df" command the columns of the output are not aligned.

Code:
QMN012:.../oracle> df -k
Filesystem    1024-blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           524288    439592   17%     5423     6% /
/dev/M121A_HOME     3080192   2343764   24%     7263     2% /M12SAN1A/HOME
/dev/M121A_APPL      524288    523332    1%        3     1% /M12SAN1A/appl
/dev/M121A_ADMIN      524288    517004    2%      206     1% /M12SAN1A/admin
/dev/M121A_MRQ      524288    523064    1%       33     1% /M12SAN1A/MRQ
/dev/M121A_DN      524288    520040    1%      339     1% /M12SAN1A/dn
/dev/M121A_DONNEES    15728640  15725464    1%      502     1% /M12SAN1A/donnees

Is there a way to format the output of the "df" command so all columns are aligned and it is more readable ?


Last edited by Perderabo; 07-06-2005 at 05:21 PM.. Reason: Add code tags for readability
# 2  
Old 07-06-2005
Code:
#! /bin/nawk -f
#
# formatDF.nawk 
#

{

           for(i=0;i<=NF;i++){
                     lineArray[NR,i] = $i
                     if ( NF > numFields ) numFields = NF
                     if ( length($i) > lineLength[i] ) lineLength[i] = length($i)
           }
}
END{
           for(x=1;x<=NR;x++){
                if ( x == 1 ){
                     for(y=1;y<numFields-1;y++){
                               printf("%-"lineLength[y]"s ", lineArray[x,y])
                        }
                        printf("%s %s\n", lineArray[x,numFields -1], lineArray[x,numFields])
                }
                else {
                for(y=1;y<=numFields;y++){
                          printf("%-"lineLength[y]"s ", lineArray[x,y])
                }
                printf("\n")
                }
           }
}

Code:
df -k | formatDF.nawk

This is written purely for the output of df -k/df -h. It is not intended as a general column allignment script.
This User Gave Thanks to reborg For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mail sent from variable is not aligned in shell script

Hi Folks :( Scenario, Compared two values in two different files, if file1 value is greater than the value of file2 it trigger mail, I tried this, echo ${usep}; echo ${usep1}; for i in ${!usep}; do if } -gt 80 ]; then if } -gt ${usep1} ]; then ... (9 Replies)
Discussion started by: viay
9 Replies

2. Shell Programming and Scripting

Re-aligned text file into one raw

Hi, Anyone can help on how to re-aligned the data into one raw; Input Text File: TESTA Carbon A China 06/28/2016 Active Vol. 8210, No. 2048, New Era 02/25/2010 ... (1 Reply)
Discussion started by: fspalero
1 Replies

3. Shell Programming and Scripting

[SH] TUI not always properly aligned

Heyas I havent found a thread to introduce, so i combine it with the issue i have. EDIT /* Removed Problem because solved */ My first contact with Linux was back in 1995 with slackware, beeing a gamer back then, i (sadly) didnt bother to dig deeper. I finaly joined the Linux community in... (0 Replies)
Discussion started by: sea
0 Replies

4. Shell Programming and Scripting

Combine columns from many files but keep them aligned in columns-shorter left column issue

Hello everyone, I searched the forum looking for answers to this but I could not pinpoint exactly what I need as I keep having trouble. I have many files each having two columns and hundreds of rows. first column is a string (can have many words) and the second column is a number.The files are... (5 Replies)
Discussion started by: isildur1234
5 Replies

5. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

6. Solaris

Partition 0 not aligned on cylinder boundary: "

hi Guys .. user want mirror disk c3t9d0 (running ) to c2t9d0 (fresh hdd). when i tried to bash : prtvtoc /dev/rdsk/c3t9d0s2 | fmthard -s- /dev/rdsk/c2t9d0s2 it showing following error Partition 0 not aligned on cylinder boundary: " 0 4 222 ..... unable to mirror .... plz... (1 Reply)
Discussion started by: coolboys
1 Replies

7. Shell Programming and Scripting

Output columns needs to be aligned

Hi All I'm running a shell script and the output is something like: Col1 Col2 Col3 aaaa aaaaaaa aaaaa bbbbb bbbbb bbbbbb ccc cccccc ccccccc But I require the output to printed as given below: Col1 Col2 Col3 aaaa ... (4 Replies)
Discussion started by: nkamalkishore
4 Replies

8. Shell Programming and Scripting

SQL output vertically aligned?

I used the SQL query (taken from other threads here) to get the expected values to be written into a file. myQuery=`sqlplus -s cr_appsrvr/appsrvr@qwi << EndofFile set heading off; set tab off; set wrap off; set pages 0; set feedback off; SELECT CLEARINGHOUSE_TRACE_NUM, INSURED_ID FROM... (4 Replies)
Discussion started by: swame_sp
4 Replies

9. Shell Programming and Scripting

[bash scripting] Generating a table with aligned fields

Hi everyone, I want to write a function which calculates the space needed between fields, to generate a table with aligned fields, like when you type "ls -l", the operating system generates a table with beautifully aligned fields. I've got this code so far: for line in $(cat tmpSearch)... (2 Replies)
Discussion started by: Aveltium
2 Replies

10. Solaris

Error: Memory Address Not aligned

Hi, The following error message occured when I was trying to reboot my SUN machine: Memory address not aligned Its a Sun 280 R , Ultra SPARC III What should I do. Varma (3 Replies)
Discussion started by: gunnervarma
3 Replies
Login or Register to Ask a Question