All pastes #279269 Raw Edit

Get last n character

public shellscript v1 · immutable
·published 2006-12-14 22:24 UTC
rendered paste body
#!/bin/shget_last_n() {    n="$1"; shift; str="$@"        length=$(echo $str | wc -m)    pos=$(( length - n ))    echo $str | cut -c"$pos-"}my_str="This is my string."last_three=$(get_last_n 3 $my_str)echo $last_three