[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=$'
'
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

  

原文地址:https://www.cnblogs.com/shadow21/p/3548782.html