我想获得使用字符串的一部分cut
。 这里的虚拟实例:
$ echo "foobar" | cut -c1-3 | hexdump -C
00000000 66 6f 6f 0a |foo.|
00000004
注意\n
在结束时加入炭。
在这种情况下,没有一点用cut
删除最后一个字符如下:
echo "foobar" | cut -c1-3 | rev | cut -c 1- | rev
我仍然会得到这额外和不必要的字符,我想避免使用额外的命令,例如:
shasum file | cut -c1-16 | perl -pe chomp