Is there such an option so that dos2unix can be applied recursively to matching files ?
3 Answers
You can use find
to select the files which you want to alter. And use xargs to pass filenames to dos2unix.
find . -iname '*.tpl' | xargs dos2unix
If you want to limit the search to the two directories ww1 and ww2 you can use the following command
find /var -iname '*.tpl' -regex '/var/ww[1,2]/.+' | xargs dos2unix
-
-
-
3Also, have a look at the man page for find
man find
and see if you can teach yourself to fish. Nov 24, 2010 at 8:44 -
@yoyo:
find /var/ww[12] -iname "*.tpl" -print0 | xargs -0 dos2unix
Nov 24, 2010 at 14:16
If you are are using zsh
you can simply do:
dos2unix **/*.tpl
Which will recursively search all .tpl files for you without the need to rely on find
.
-
2
In addition to the xargs
solution, you can do find . -iname '*.tpl' -execdir dos2unix {} +
. (Or just -exec
on older versions of find
— the end effect is the same.)