Try this (takes 5 repetitions of the character "any" at the beginning of the line and saves it in the first group, then randomly repeat any characters and replace the line with the first group):
sed 's/^\(.\{5\}\).*/\1/'
Or an alternative suggested by mouviciel:
sed 's/^\(.....\).*/\1/'
(this is more readable if the number of first characters you want is not too large)
source share