The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to add a single line to middle of text file. progkcp Shell Programming and Scripting 2 05-12-2008 03:44 PM
ls command output in single line arsheshadri AIX 7 04-28-2008 03:50 PM
Single line file editing command? gator76 Shell Programming and Scripting 1 04-03-2008 11:09 AM
Multi-line output to single line LinuxRacr Shell Programming and Scripting 7 02-26-2008 10:05 AM
Need output in different lines not in one single line csaha Shell Programming and Scripting 1 02-08-2006 08:28 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2008
shew01 shew01 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 41
Can df output be forced to a single line for each file system?

df generates the following output on one of our systems:


Code:
df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/vx/dsk/rootvol    4131866   3593316    497232  88% /
swap                  19963152       144  19963008   1% /var/run
swap                  19985184     22176  19963008   1% /tmp
/dev/vx/dsk/u01      112302757  30834420  80345310  28% /u01
/dev/vx/dsk/node@1       96975      4977     82301   6% /global/.devices/node@1
/dev/vx/dsk/node@2       96975      4988     82290   6% /global/.devices/node@2
/dev/vx/dsk/stkdg/s03
                     1047527424  60483821 925353439   7% /s03
/dev/vx/dsk/stkdg/s02
                     1048576000 266825846 732890795  27% /s02
/dev/vx/dsk/sandg/s01
                     355923968 322686891  31315266  92% /global/s01


Is there a way to force the output to display each Filesystem on a single line instead of splitting the lines after the first column? For example, I am trying to get the output to look like this:


Code:
df -k
Filesystem             1K-blocks      Used Available Use% Mounted on
/dev/vx/dsk/rootvol      4131866   3593316    497232  88% /
swap                    19963152       144  19963008   1% /var/run
swap                    19985184     22176  19963008   1% /tmp
/dev/vx/dsk/u01        112302757  30834420  80345310  28% /u01
/dev/vx/dsk/node@1         96975      4977     82301   6% /global/.devices/node@1
/dev/vx/dsk/node@2         96975      4988     82290   6% /global/.devices/node@2
/dev/vx/dsk/stkdg/s03 1047527424  60483821 925353439   7% /s03
/dev/vx/dsk/stkdg/s02 1048576000 266825846 732890795  27% /s02
/dev/vx/dsk/sandg/s01  355923968 322686891  31315266  92% /global/s01

  #2 (permalink)  
Old 06-04-2008
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
Try...
Code:
df -Pk

  #3 (permalink)  
Old 06-05-2008
shew01 shew01 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 41
Is there another way? Our version of Unix (Solaris 8) does not support it.


Code:
df -Pk
df: unknown option: P
Usage: df [-F FSType] [-abegklntVv] [-o FSType-specific_options] [directory | block_device | resource]

  #4 (permalink)  
Old 06-05-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,311
-P stands for
Quote:
portability
use the POSIX output format
Maybe check the df man page on Solaris for something similar?
  #5 (permalink)  
Old 06-05-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926

Code:
df -k|cat

(...)

Note: if you redirect or pipe to other process, you don't need cat:


Code:
$ df -k /
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/vx/dsk/bootdg/rootvol
                     5043518 4735581  257502    95%    /
$ df -k /|cat
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/vx/dsk/bootdg/rootvol 5043518 4735581  257502    95%    /
$ df -k />t;cat t
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/vx/dsk/bootdg/rootvol 5043518 4735581  257502    95%    /

Or, with some shells (if you don't mind the (ba|k)sh: __: part ):


Code:
${__?"$(df -k)"}

or:


Code:
printf "%s\n" "$(df -k)"


Last edited by radoulov; 06-05-2008 at 11:04 AM..
  #6 (permalink)  
Old 06-05-2008
shew01 shew01 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 41
zaxxon,

For whatever reason, we have at least two versions of df installed. One version says that -P is essentially the same as -k.

I'm still getting split lines with the second version of df that I found.

Thanks for the idea though.
  #7 (permalink)  
Old 06-05-2008
shew01 shew01 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 41
radoulov,

This seems to work. Thanks!
Closed Thread

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0