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

1

5

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

Macmillan answered 8/12, 2017 at 10:9 Comment(0)
L
14

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

Laurettelauri answered 8/12, 2017 at 10:27 Comment(1)
thank you, it works! now I want to do qsub *.sh for all the files as well. I tried find . -type f -name "*.sh" -exec qsub {} \+;, but why only one job was submitted?Macmillan

© 2022 - 2024 — McMap. All rights reserved.