我有字符串列表:
./index.blade.php core/resources/views/admin/pages/setting/index.blade.php
./country-flag vendor/country-flag
我只想获取空格后的字符串,我应该如何在 sed 或 awk 中编写它?
我尝试过,但没有成功
echo "./country-flag vendor/country-flag" | awk '/^[[blank]]/{p=1}p'
预期输出:
vendor/country-flag
最佳答案
默认情况下,awk
中的字段分隔符是空格
,因此我们可以借助$2
引用空格后的第二个字段
echo "./country-flag vendor/country-flag" | awk '{print $2}'
vendor/country-flag
关于shell - 如何使用 sed 或 awk 获取字符串中空格后的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66775781/