bash - How do I truncate the last two characters of all files in a directory? -
this question has answer here: bash script remove 'x' amount of characters end of multiple filenames in directory? 3 answers so pretty simple question. of files in directory of form 6bfefb348d746eca288c6d62f6ebec04_0.jpg . want them 6bfefb348d746eca288c6d62f6ebec04.jpg . essentially, want take off _0 @ end of every file name. how go doing bash? with perl's standalone rename command: rename -n 's/..(\....)$/$1/' * if looks fine, remove -n . it possible use standalone rename command syntax similar sed 's s/regexp/replacement/ command. in regex . matches 1 character. \. matches . , $ matches end of line (here end of filename). ( , ) special characters in regex mark subexpression (here 1 . , 3 characters @ end of filename) can reused $1 . sed uses \1 first back-reference, rename uses $1 . see: back-references , sub