What is a unix command for deleting the first N characters of a line?

前端 未结 6 1408
悲&欢浪女
悲&欢浪女 2020-11-30 17:27

For example, I might want to:

tail -f logfile | grep org.springframework | 

I was thinking that

6条回答
  •  渐次进展
    2020-11-30 17:39

    I think awk would be the best tool for this as it can both filter and perform the necessary string manipulation functions on filtered lines:

    tail -f logfile | awk '/org.springframework/ {print substr($0, 6)}'
    

    or

    tail -f logfile | awk '/org.springframework/ && sub(/^.{5}/,"",$0)'
    

提交回复
热议问题