[英]Parsing a variable in shell scripting
I am new to shell scripting just started off. 我是刚开始使用Shell脚本的新手。 I have written this script
我已经写了这个脚本
#!/bin/sh
profile_type= cat /www/data/profile.conf
echo $profile_type
the o/p of this script is 该脚本的o / p为
. /tmp/S_panicA1.txt
. /tmp/S_panicA0.txt
away_Def="panicA1 panicA0"
away_Byp=0
away_Sts=$((panicA1+panicA0-away_Byp))
In this i want to get panicA1 panicA0 and 0 and store it in other variable how to do this? 在这个我想得到panicA1 panicA0和0并将其存储在其他变量中怎么办呢?
When you want to assign the output of a command to a variable, you use the dollar parenthesis syntax. 若要将命令的输出分配给变量,请使用美元括号语法。
foo=$(cat /my/file)
You can also use the backticks syntax. 您还可以使用反引号语法。
foo=`cat /my/file`
In your script, you simply run the command cat
and assign its result, nothing, to your variable. 在脚本中,您只需运行命令
cat
并将其结果(不分配任何内容)分配给变量。 Hence the output consisting of the content of your file, result of cat
, followed by an empty line, result of echo
with an empty variable. 因此,输出包含文件内容,
cat
结果,后跟空行, echo
结果和空变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.