什么是删除一行前 N 个字符的 unix 命令?

人气:217 发布:2022-10-16 标签: unix command truncate bash

问题描述

例如,我可能想:

tail -f logfile | grep org.springframework | <command to remove first N characters>

我在想 tr 可能有能力做到这一点,但我不确定.

I was thinking that tr might have the ability to do this but I'm not sure.

推荐答案

使用cut.例如.去除每行的前 4 个字符(即从第 5 个字符开始):

Use cut. Eg. to strip the first 4 characters of each line (i.e. start on the 5th char):

tail -f logfile | grep org.springframework | cut -c 5-

655