我有一个字符串:
Log for: squid.log.2017.11.13
我需要删除 squid.log.
以便我看到:
Log for: 2017.11.13
我尝试剪切
echo "Log for: squid.log.2017.11.13" | cut -d'.' -f3-5
但我最终得到了:
2017.11.13
我怎样才能得到我想要的结果?
最佳答案
您可以使用sed
删除不需要的部分:
echo "Log for: squid.log.2017.11.13" | sed 's/squid\.log\.//'
关于Bash,从字符串中用点字符剪切单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47295992/