My tr is version 5.2.1, and does not exhibit this problem.
I tried:
Code:
echo "test-3" | tr --delete 'test-'
and the result was 3.
A bit of warning: tr will delete all characters within the character set 'test-', not simply all occurences of the string 'test-'. So the result of
Code:
echo "t-t-e-e-s-s-t-t-3-testtest" | tr --delete 'test-'
is also 3. (And, because the argument to tr is a character set rather than a string, the second t is redundant.)
Anyway, the fact that each of these filenames has already been matched with test-* by the for loop, means that whatever program you use to remove the leading 6 characters does not need to retest for the presence of the prefix (its presence is already guaranteed by the pattern matching). Piping to:
should be simple enough. Just don't forget the last dash after the 6.
If the prefix might change in the future, you could always have bash calculate the new cut location by checking the length of the prefix and adding 1:
Code:
#!/bin/bash
prefix="removeme-"
cut_location=$(( ${#prefix}+1 ))
for f in "$prefix"*
do
echo "$f" | cut -c$cut_location-
done