To get the first X letters of a word:
It's very simple you can just pipe it to head with
echo "dsjfsdlksjdklf;jlsd;kflasdj;kl"|head -c 2
Returns ds
To get the last X letters of a word:
Now we use tail with -c but it works differently. You will want to start with 2 otherwise you will get the end of the string which is nothing.
echo "dsjfsdlksjdklf;jlsd;kflasdj;kl"|tail -c 2
Returns "l"
echo "dsjfsdlksjdklf;jlsd;kflasdj;kl"|tail -c 3
Returns "kl"
bash, linux, wordto, echo, quot, dsjfsdlksjdklf, jlsd, kflasdj, kl, returns, ds,