The question is a bit unclear - the above example may mean that you want to delete all #s or delete the part after the last "." or delete the part after the first "1" or even delete all characters after the symbol 13. Please clarify.
If you want to delete the first N characters in the string (for example, "before character number 13"), do echo testFile.txt.1 | cut -c14- echo testFile.txt.1 | cut -c14- . On the other hand, to save characters 1-13, do echo testFile.txt.1 | cut -c1-13 echo testFile.txt.1 | cut -c1-13
If you mean that you want to delete the initial characters before the first occurrence of a certain character (in your example, which seems to be โ1โ), do echo testFile.txt.1 | perl -e 's/^[^1]*//;' echo testFile.txt.1 | perl -e 's/^[^1]*//;' . To delete everything AFTER the first "1", do echo testFile.txt.1 | perl -e 's/1.*$//;' echo testFile.txt.1 | perl -e 's/1.*$//;'
If you want to remove all #s, do echo testFile.txt.1 | perl -e 's/\d//g;' echo testFile.txt.1 | perl -e 's/\d//g;' or without Perl, echo testFile.txt.1 | tr -d "[0-9]" echo testFile.txt.1 | tr -d "[0-9]"
If you want to delete everything after the last ".", Do echo testFile.txt.1 | perl -e 's/\.[^.]+/./;' echo testFile.txt.1 | perl -e 's/\.[^.]+/./;'
DVK
source share