Unix [SOLVED]: print df -h output in one line in ksh shell

Unix [SOLVED]: print df -h output in one line in ksh shell

Home Forums Unix Unix [SOLVED]: print df -h output in one line in ksh shell

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #37024

    Anonymous

    QuestionQuestion

    I want to print df -h output in one line.
    Our FS name is very long because of which df -h output is going in another line.

    after using df -PH in bash shell, I am able to print command output in one line but df -PH is not working in ksh shell.

    How to print df -h output in one line in KSH shell?

    For example

    Filesystem             size   used  avail capacity  Mounted on 
    /plorm/su/lb/lir/l_pap3rs_90_lib 
       16G   5.9G   9.4G    39%    /plrm/sv/ib/li1 
    

    This should come

    Filesystem             size   used  avail capacity  Mounted on   
     /plorm/su/lb/lir/l_pap3rs_90_lib   16G   5.9G   9.4G    39%    /plrm/sv/ib/li1 
    

    Thanks.

    #37025

    Anonymous

    Accepted AnswerAnswer

    try:

    COLUMNS=1000 df -h
    

    or:

    df -h | awk 'NF==1{printf "%s", $0; next}1'
    

    or:

    df -h | awk 'NF!=1; NF==1{ printf "%s", $0}'
    

    Source: https://stackoverflow.com/questions/48009975/print-df-h-output-in-one-line-in-ksh-shell
    Author: William Pursell
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.