Softest卧龙 发表于 2022-12-7 16:47:33

一道shell题

    Exercise_3 - Store the output of the command “hostname” in a variable. Display “This script is running on _.” where “_” is the output of the “hostname” command.(原文)
翻译:将命令“hostname”的输出存储在一个变量中。显示“此脚本正在_上运行。”其中“_”为hostname命令的输出。

思路:
#!/bin/bashHOSTNAME=$(hostname)
echo “This script is running on $HOSTNAME”

Output(要求输出结果)

$ ./exe3.sh
This script is running on vimukthi

xiaoshuai666 发表于 2022-12-9 17:30:24

#!/bin/bash

HOSTNAME=$(hostname)

echo "This script is running on $HOSTNAME"
页: [1]
查看完整版本: 一道shell题