//View Tip #190
Similar Tips
» Find files by mime-type
» Duplicate directory tree
» Randomized find
» Rename many files using find and perl
» Directory Tree

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
dos2unix requires the name of an input and output file so it can be hard to run on a list of files. The following gets around this and will run dos2unix on all files in a directory:

for f in `find * -type f`; do echo "dos2unix $f $f"; done | sh


View Comments »




Comments 

Add your comment

Comments are currently disabled
ughh!!

 for f in *; do [[ -f $f ]] && dos2unix "$f" "$f"; done

1) don't generate programs that output lists of files if the shell can give them to you (`find * -type f`)
2) don't "echo" commands to pipe to sh if you can call them directly (echo "dos2unix $f $f" ... | sh)
Posted 2009-02-14 02:40:19
...and if you want it to be recursive (like the OP) do:

 find . -type f -exec dos2unix {} {} ';'
Posted 2009-02-15 18:30:25

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit