[ISSUE]shell 命令问题

###

对于路径中带空格的,加上引号,比如 ./"JS Crystal Craze Mac.app/Contents/MacOS/JS Crystal Craze Mac"

如果是在遍历的路径中带有空格,如何处理

http://unix.stackexchange.com/questions/9496/looping-through-files-with-spaces-in-the-names

摘录:

Short answer (closest to your answer, but handles spaces)

OIFS="$IFS"
IFS=$'\n'
for file in `find . -type f -name "*.csv"`  
do
     echo "file = $file"
     diff "$file" "/some/other/path/$file"
     read line
done
IFS="$OIFS"

Better answer (also handles wildcards and newlines in file names)

find . -type f -name "*.csv" -print0 | while IFS= read -r -d '' file; do
    echo "file = $file"
    diff "$file" "/some/other/path/$file"
    read line </dev/tty
done

 

###

shell 中关闭蜂鸣器:setterm -blength 0

  

posted on 2014-02-13 22:54  影语者  阅读(302)  评论(0编辑  收藏  举报

导航