【shell】用sed获取最后一个字符

来源:互联网 发布:http error 500 php 编辑:程序博客网 时间:2024/06/07 00:35

1. 输入:echo "hello" | sed 's/\(.*\)\(.\)$/\1/'

    输出:o


2. 输入:echo "hello" | sed 's/\(.*\)\(.\)$/\2/'

    输出:hell


注:\(...\)是分组的意思


原创粉丝点击