格式化命令的输出

hes*_*bar 0 bash system-information text-formatting

我目前正在尝试使用 Plink 在 linux 服务器上运行一些命令来监视它上的一些事情,例如磁盘空间、内存、cpu 使用情况。
我有我想使用的命令,但我想将输出格式化为更易于阅读的内容。
这是我在批处理文件中使用的命令。

 FOR /F "" %%G IN (C:\Users\username\Desktop\ip_list.txt) DO "C:\Program Files\PuTTY\plink.exe" -ssh -batch username@%%G -pw password "hostname; df | fgrep '/dev/'; free -h; top -bn2 | grep 'Cpu(s)';"
Run Code Online (Sandbox Code Playgroud)

这是我得到的输出
在此处输入图片说明
基本上,我只想在各个命令输出之间添加一些行,以使其更易于阅读。如果不将输出写入文本文件,这可能吗?
谢谢

小智 5

这可以通过在需要空格的命令中间添加echo ""来实现。

这里有一些例子。

  1. 在中间添加新行。

例子:

 df | fgrep '/dev/'; echo ""; free -h
Run Code Online (Sandbox Code Playgroud)

输出

 tmpfs                                    16334344       55772  16278572   1% /dev/shm

              total        used        free      shared  buff/cache   available
Mem:            31G        4.0G         21G        346M        6.0G         26G
Swap:           15G        2.3M         15G
Run Code Online (Sandbox Code Playgroud)
  1. 添加命令的详细信息。

受到推崇的

例子:

echo "==================" ; echo "This is output of df"; echo "==================" ;df | grep '/dev/shm' ; echo ""; echo "==================" ; echo "This is output of Free"; echo "==================";free -h
Run Code Online (Sandbox Code Playgroud)

输出:

==================
This is output of df
==================
tmpfs                                    16334344       55772  16278572   1% /dev/shm

==================
This is output of Free
==================
              total        used        free      shared  buff/cache   available
Mem:            31G        4.0G         21G        359M        6.0G         26G
Swap:           15G        2.3M         15G
Run Code Online (Sandbox Code Playgroud)