Bash command to remove leading zeros from all file names

前端 未结 8 1849
一整个雨季
一整个雨季 2021-02-08 23:35

I have a directory with a bunch of files with names like:

001234.jpg
001235.jpg
004729342.jpg

I want to remove the leading zeros from all file

8条回答
  •  无人共我
    2021-02-09 00:13

    I dont know sed at all but you can get a listing by using find:

    find -type f -name *.jpg

    so with the other answer it might look like

    find . -type f -name *.jpg | sed -e 's:^0*::'

    but i dont know if that sed command holds up or not.

提交回复
热议问题