Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试打印出我的 IP 地址以及前面的评论。我不知道如何在一行中完成所有操作。
6 alias showip="ifconfig | grep 'inet' | sed -n '5p' | tr -s ' ' | cut -d ' ' -f2" 11 ip=showip 12 ip="ip: $ip" 13 echo ip
我正在寻找的输出类似于:
ip: 192.168.1.2
谢谢一群人。
printf 'ip: %s\n' $(showip)
更新:问题已解决
我不确定我是否理解您的问题,但您可能正在寻找:
printf 'ip: %s\n' $(ifconfig | grep 'inet' | sed -n '5p' | tr -s ' ' | cut -d ' ' -f2)