formatting out put of Df -kh /myhome/


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting formatting out put of Df -kh /myhome/
# 1  
Old 10-08-2012
formatting out put of Df -kh /myhome/

Hello All,

I need to formate out put of
Code:
df -kh /myhome/
 
Filesystem size used avail capacity Mounted on
/dev/vx/dsk/esgdg/opt_xxxxxxxxx
50G 5.7G 42G 13% /opt/xxxxdir
 
In following formate:
FileSystem --> /dev/vx/dsk/esgdg/opt_empowered
Size -->50G

etc...

Can someone help me?

Thanks
Krsna

Last edited by krsnadasa; 10-08-2012 at 06:10 AM..
# 2  
Old 10-08-2012
try this..

Code:
df -kh | awk '{if(NR==1){FV=$1;SV=$2}else if(!(NR%2)){print FV,$1 }else{print SV,$1}}' OFS=" --> "

# 3  
Old 10-08-2012
formating out put of Df -kh /myhome/

Hi pamu,

This is giving me only this :
Code:
 df -kh . | awk '{if(NR==1){FV=$1;SV=$2}else if(!(NR%2)){print FV,$1 }else{print SV,$1}}' OFS=" --> "

Out out:

Code:
Filesystem --> /dev/dsk/c0t0d0s5

Thanks
Krsna
# 4  
Old 10-08-2012
Quote:
Originally Posted by krsnadasa
Code:
 df -kh . | awk '{if(NR==1){FV=$1;SV=$2}else if(!(NR%2)){print FV,$1 }else{print SV,$1}}' OFS=" --> "

What you are trying to do..?
check the output of df -kh .
# 5  
Old 10-08-2012
Hi Pamu,

Sorry for confusion. Actually I am in some dir and I am executing cmd
Code:
df -kh . ( in current dir) gives output in formate
 
Filesystem size used avail capacity Mounted on
/dev/vx/dsk/esgdg/opt_xxxxxxxxx
50G 5.7G 42G 13% /opt/xxxxdir

i want this out put come in different format like :
 
Filesystem ---> /dev/vx/dsk/esgdg/opt_xxxxxxxxx
size ---> 50G
used ---> 5.7G
avail ---> 42G
capacity ---> 13% 
Mounted on ---> /opt/xxxxdir

Hope I am clear now?
Thanks
Krsna
# 6  
Old 10-08-2012
try this..


Code:
awk 'NR==1{n=split($0,a," ")}
NR>1{if($0 ~ /^\//){print a[1],$0}else{for (i=2;i<=(n-1);i++){print a[i],$(i-1)}{print a[n-1]" "a[n],$NF}}}' OFS=" --> " file

# 7  
Old 10-08-2012
Try
Code:
df -kh .|awk 'NR==1 {split($0,B);next} {for (i=1;i<=NF;i++) print B[i],"-->",$i}'

This User Gave Thanks to RudiC 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

Formatting data to put it in the excel file

Hello, I have a file with the below contents : Policy Name: Backup_bkp Policy Type: Catalog_bkp Active: yes Effective date: 08/07/2013 02:02:12 Mult. Data Streams: no Client Encrypt: no Checkpoint: no Policy Priority: ... (11 Replies)
Discussion started by: rahul2662
11 Replies

2. Shell Programming and Scripting

SFTP PUT

Hi, ServerA (SFTP server) ServerB (SFTP client) ServerB:> sftp user@ServerA ServerB:> put sample.txt ServerB:> get sample2.txt My question is that which machine will encrypt the sample.txt and sample2.txt files. Thanks (8 Replies)
Discussion started by: Arpit Narula
8 Replies

3. Solaris

How to sort df -h out put :

Hello every one , I am just trying to sort df -h out in a particular order to differentiate SAN disks and local disks .. does any body have any script or any useful command ?? thanks in advance .. (8 Replies)
Discussion started by: new2uniks
8 Replies

4. UNIX for Advanced & Expert Users

How to get this out put ?

How to get to know, where are the current logs been updated in the system or most recently updated logs in the system. consider /usr/abc/def and inside the def folder , i have many subfolders The command out put ,need to give me the log files and there location , which are... (7 Replies)
Discussion started by: sidharthmellam
7 Replies

5. UNIX for Dummies Questions & Answers

put $,.

original content: 0000000000 TIAA-CREF 0000000000 CAREMARK all said and done, i'd like to look like this: $00,000,000.00 TIAA-CREF $00,000,000.00 CAREMARK (2 Replies)
Discussion started by: tjmannonline
2 Replies

6. Shell Programming and Scripting

how to put it in a column

Simple question ..What is the easiest way to list my output in a column like so dddd dddd dddd dddd output dddd dddd dddd dddd Thanks (3 Replies)
Discussion started by: bombcan
3 Replies

7. Shell Programming and Scripting

how to put those in Dbase

Hi Experts, I have a file which contains- .. .. <?xml version='1.0' encoding='ISO-8859-1' standalone='no'?> <LogItems> <log logid="83efeae5190809080000080410"> <category>Upstream.TEL</category> <operation>MAKE</operation> <target>mms</target> <user>purple</user>... (3 Replies)
Discussion started by: thepurple
3 Replies

8. Shell Programming and Scripting

How to put the default value

Hi guys Iam looking for a small help.I wrote a script. in that iam trying to take the default value ,when we press enter.this part iam struggling can somebody help please Example: do u need this server: For this one if we press enter it has to take server name as... (4 Replies)
Discussion started by: coolkid
4 Replies

9. Shell Programming and Scripting

how to put a # in a file

Hello, Sir's, I would like to ask for help. This is my problem, i am working for a mbs for aix,hp-ux and solaris. And i am making a script that will automatically implement the said mbs. For example it will automatically change the permmisions of /usr/bin, /etc/passwd and so on. . . .... (7 Replies)
Discussion started by: invinzin21
7 Replies

10. UNIX for Dummies Questions & Answers

help need help on wine how to put in

how the hell do you put wine in because i don't know i have mandrake please tell how to put in (1 Reply)
Discussion started by: amicrawler
1 Replies
Login or Register to Ask a Question