Using 'find' to return filenames without e

2019-02-23 15:01发布

I have a directory (with subdirectories), of which I want to find all files that have a ".ipynb" extension. But I want the 'find' command to just return me these filenames without the extension.

I know the first part:

find . -type f -iname "*.ipynb" -print    

But how do I then get the names without the "ipynb" extension? Any replies greatly appreciated...

7条回答
孤傲高冷的网名
2楼-- · 2019-02-23 15:28

If you need to have the name with directory but without the extension :

find .  -type f -iname "*.ipynb" -exec sh -c 'f=$(basename $1 .ipynb);d=$(dirname $1);echo "$d/$f"' sh {} \;
查看更多
登录 后发表回答