如何在BusyBox容器中打印Unix工具的版本?

huangapple go评论53阅读模式
英文:

How to print unix tool version in BusyBox container?

问题

我无法弄清楚如何在BusyBox容器中打印(unix工具)的版本:

```bash
$ docker run -it quay.io/quay/busybox:latest
$ awk --version
awk: 未识别的选项 `--version'
BusyBox v1.32.0 (2020-08-31 17:40:13 UTC) 多功能调用二进制文件。

用法:awk [选项] [AWK_PROGRAM] [文件]...

        -v VAR=VAL      设置变量
        -F SEP          使用SEP作为字段分隔符
        -f FILE         从FILE中读取程序
        -e AWK_PROGRAM
$ cut --version
cut: 未识别的选项 `--version'
BusyBox v1.32.0 (2020-08-31 17:40:13 UTC) 多功能调用二进制文件。

从每个输入文件中打印所选字段到stdout

        -b LIST 仅从LIST中输出字节
        -c LIST 仅从LIST中输出字符
        -d CHAR 使用CHAR而不是制表符作为字段分隔符
        -s      仅输出包含分隔符的行
        -f N    仅打印这些字段
        -n      忽略

有什么建议吗?许多mulled容器都是基于BusyBox构建的,最好了解一下。

谢谢


<details>
<summary>英文:</summary>

I can&#39;t figure out how to print (unix tool) versions within a BusyBox container:

```bash
$ docker run -it quay.io/quay/busybox:latest
$ awk --version
awk: unrecognized option `--version&#39;
BusyBox v1.32.0 (2020-08-31 17:40:13 UTC) multi-call binary.

Usage: awk [OPTIONS] [AWK_PROGRAM] [FILE]...

        -v VAR=VAL      Set variable
        -F SEP          Use SEP as field separator
        -f FILE         Read program from FILE
        -e AWK_PROGRAM
$ cut --version
cut: unrecognized option `--version&#39;
BusyBox v1.32.0 (2020-08-31 17:40:13 UTC) multi-call binary.

Usage: cut [OPTIONS] [FILE]...

Print selected fields from each input FILE to stdout

        -b LIST Output only bytes from LIST
        -c LIST Output only characters from LIST
        -d CHAR Use CHAR instead of tab as the field delimiter
        -s      Output only the lines containing delimiter
        -f N    Print only these fields
        -n      Ignored

Any suggestions? Many mulled containers are built on top of BusyBox, best I get on top of this.

Thanks

答案1

得分: 1

busybox 是一个单一的程序,根据调用它的名称,充当各种工具之一。正如您在问题中所见,它显示其版本为 BusyBox v1.32.0

检查哪些工具是指向 busybox 的符号链接。所有这些工具都是相同的程序,因此具有相同的版本,所以您可能只需要 busybox 的版本和与之链接的命令列表。

根据 https://unix.stackexchange.com/q/15895/330217,显示 busybox 版本的最佳方法是

busybox | head -1
英文:

busybox is a single program which acts as one of various tools depending on what name was used to call it. As you can see in the question, it shows its version as BusyBox v1.32.0.

Check which tools are (symbolic) links to busybox. All these are the same program and therefore have the same version, so you might only need the version of busybox and a list of commands linked to it.

According to https://unix.stackexchange.com/q/15895/330217 the best way to display the version of busybox is

busybox | head -1

huangapple
  • 本文由 发表于 2023年2月8日 17:46:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/75383910.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定