为什么我不能使用 -o 或 --format 和 ps 命令来控制输出格式?
Why am I not able to use -o or --format with ps command to control the output format?
我只想从 ps
输出中打印某些列,即 PID、PPID、命令、内存利用率和 CPU 利用率列。
当我使用 运行 ps
命令时,我得到以下输出。
现在我只想要此输出中的一些列,所以我使用 -o 标志,如 tutorial 中所述。
但是我收到了这个错误。
我不明白问题出在哪里。我也试过使用 --help
但它没有显示 -o
标志。所以我在这里很困惑。
我使用的是windows操作系统。并使用 Git Bash 终端 到 运行 所有这些 Linux 命令。
Git Bash 是 Windows 的终端,它模拟 Linux bash (shell) 的功能。它不是 100% 兼容“真实的”bash shell。正如您根据经验所见,它的 ps
可执行文件不支持您从 Linux 中习惯使用的所有标志。 --help
选项将显示支持的标志。
Hello
Maybe put 2 things together, ps and grep? Then try this...
ps | grep -o -E "^[ 0-9]{1,9}"
...and is this working on your system?
( The Space in [ ] is important )
我只想从 ps
输出中打印某些列,即 PID、PPID、命令、内存利用率和 CPU 利用率列。
当我使用 运行 ps
命令时,我得到以下输出。
现在我只想要此输出中的一些列,所以我使用 -o 标志,如 tutorial 中所述。
但是我收到了这个错误。
我不明白问题出在哪里。我也试过使用 --help
但它没有显示 -o
标志。所以我在这里很困惑。
我使用的是windows操作系统。并使用 Git Bash 终端 到 运行 所有这些 Linux 命令。
Git Bash 是 Windows 的终端,它模拟 Linux bash (shell) 的功能。它不是 100% 兼容“真实的”bash shell。正如您根据经验所见,它的 ps
可执行文件不支持您从 Linux 中习惯使用的所有标志。 --help
选项将显示支持的标志。
Hello
Maybe put 2 things together, ps and grep? Then try this...
ps | grep -o -E "^[ 0-9]{1,9}"
...and is this working on your system? ( The Space in [ ] is important )