#!/bin/bash #This script convert all the files within $1 directory to DOS format. #bug:can't convert files if the filename contains spaces. # -leiyu. recursive_dos2unix() { for x in $(ls) do if [ -f "$x" ] then chmod a+w ./"$x" dos2unix ./"$x" chmod a-w ./"$x" elif [ -L "$x" ] then echo "this is a link" else cd "$x" if [ "$?" != "0" ] then echo "cd failed, exit now." exit 1 fi pwd recursive_dos2unix cd .. fi done } echo "Start convert" cd $1 recursive_dos2unix echo "end of convert" |
* soft quote: " " (雙引號),在 soft quoe 中大部份 meta 都會被關閉,但某些則保留(如 $ )。(註二)
#!/bin/bash
IFS=$'\n'
...
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |