当我为serverstatus.sh
运行WebSphere
命令时,我得到以下输出
ADMU0116I: Tool information is being logged in file /opt/IBM/WebSphere/AppServer/profiles/Server1/logs/serverStatus.log ADMU0128I: Starting tool with the Server1 profile ADMU0503I: Retrieving server status for all servers ADMU0505I: Servers found in configuration: ADMU0506I: Server name: server1 ADMU0508I: The Application Server "server1" is STARTED
我想复制一个名为" server1"的特定字符串。并使用shell
脚本将其分配给变量。
答案 0 :(得分:0)
您可以像这样使用直线GNU awk
,
serverName=$( ./serverstatus.sh | awk -F':[[:blank:]]*' '/Server name/{print $3; exit}')
echo "$serverName"
server1