Get the last 4 characters of output from standard out

How about tail, with the -c switch. For example, to get the last 4 characters of "hello":

echo "hello" | tail -c 5
ello

Note that I used 5 (4+1) because a newline character is added by echo. As suggested by Brad Koch below, use echo -n to prevent the newline character from being added.


Using sed:

lspci -s 0a.00.1 | sed 's/^.*\(.\{4\}\)$/\1/'

Output:

4dc9

Do you really want the last four characters? It looks like you want the last "word" on the line:

awk '{ print $NF }'

This will work if the ID is 3 characters, or 5, as well.