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.
我正在尝试执行以下操作:
echo "test++abc" | awk -v bar="test++" 'BEGIN {FS=bar} {print $2}'
我希望看到abc输出,因为我用作bar="test++"分隔符。但我却得到++abc了。
abc
bar="test++"
++abc
谁能解释一下这种行为以及如何解决它?
非常感谢!
echo "test++abc" | awk -v bar='test[+][+]' 'BEGIN {FS=bar} {print $2}'
尝试:
echo "test++abc" | awk -v bar="test\\+\\+" 'BEGIN {FS=bar} {print $2}'
在 sed 中:
echo "test++abc" | sed -e 's/test++//'