//View Tip #190
Similar Tips
» Pipe files to an archive
» Moved Trac and Subversion repositories to another machine/direct
» Random mass-rename
» Find and replace on specific files
» Count files by type

 

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

CAPTCHA

No HTML allowed. URLs will be linked with nofollow attribute. Whitespace is preserved.

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