Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run dos2unix for all the files in subfolders in bash?

Tags:

bash

dos2unix

I am using dos2unix *.sh to convert all the .sh files in the current directory.

So how to convert all the .sh files in the subfolders as well?

I tried this but it does not work for bash: How to run dos2unix for all files in a directory and subdirecty in Powershell

like image 424
lanselibai Avatar asked Jan 29 '23 01:01

lanselibai


1 Answers

you could use find:

find . -type f -name "*.sh" -exec dos2unix {} \+;

this locates all *.sh (-name "*.sh") files (-type f) in the current directory (recursing into subdirectories as well) and executes on all of them the dos2unix utility

like image 152
ewcz Avatar answered Feb 06 '23 07:02

ewcz