How to remove filename prefix with a Posix shell
问题 How can I remove the filename prefix in Bash as in the following example: XY TD-11212239.pdf to get 11212239.pdf i.e, remove XY TD- ? 回答1: You have given very little information, but assuming you are doing this in bash, and have a list of files whose prefix needs to be removed, you can pipe the list through sed : For example: ./generate_your_list_of_files | sed -e 's/^prefix//' or if your list of files are space separated: echo TD-file1 TD-file2.x.yt TD-file3-beep | sed -e 's/\<TD-//g' The