Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
18
rated 0 times [  18] [ 0]  / answers: 1 / hits: 10349  / 2 Years ago, tue, april 19, 2022, 5:44:12

My "df -h" command on my Linux box has some devices with longer names and so the "df -h" output has line breaks (or tabs??) in it, which makes it difficult to parse the output in a script.



Does anyone know how I can suppress the linebreaks so that the latter of the following outputs is what I get:



[root@me ~]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
3.9G 404M 3.3G 11% /
/dev/mapper/VolGroup00-LogVol05
3.9G 442M 3.3G 12% /home
/dev/mapper/VolGroup00-LogVol04
3.9G 261M 3.5G 7% /var
/dev/mapper/VolGroup00-LogVol03
3.9G 137M 3.6G 4% /tmp
/dev/mapper/VolGroup00-LogVol02
7.8G 3.6G 3.8G 49% /usr


And the desired format is:



[root@me ~]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 3.9G 404M 3.3G 11% /
/dev/mapper/VolGroup00-LogVol05 3.9G 442M 3.3G 12% /home
/dev/mapper/VolGroup00-LogVol04 3.9G 261M 3.5G 7% /var
/dev/mapper/VolGroup00-LogVol03 3.9G 137M 3.6G 4% /tmp
/dev/mapper/VolGroup00-LogVol02 7.8G 3.6G 3.8G 49% /usr

More From » disk

 Answers
7

Try: df -Pkh



The P stands for "portable", and will force it to follow POSIX standard output.

I have a hunch will fix any clever formatting that df tries to do.



In the future when you try to solve problems like these, try man df and see if you can find anything that looks like it might work... cause thats what I did =)


[#43997] Tuesday, April 19, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fittecanap

Total Points: 322
Total Questions: 100
Total Answers: 105

Location: Israel
Member since Tue, Nov 17, 2020
4 Years ago
;