将sed查找结果赋值给字符串

用两个反引号 ESC下面那个键

var=`sed -n '/A/p'  1.txt`

或者

var=$(sed -n '/A/p'  1.txt)

原文地址:https://www.cnblogs.com/gelon/p/11712585.html