//View Tip #190
» Moved Trac and Subversion repositories to another machine/direct
» Random mass-rename
» Find and replace on specific files
» Count files by type
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


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)