【发布时间】:2014-04-03 04:06:54
【问题描述】:
我有一个简单的脚本/命令:
当我从 shell 运行它时:
txt=testfile
find ~/Desktop/Rory/Test -type f -exec grep $txt {} \; -exec mkdir $txt \;
结果是:
Binary file ./TEST.zip matches
and it makes a new directory named testfile
当我将它保存为 .command 时:
echo "cd: \c"
read dir
echo "txt: \c"
read str
find $dir -type f -exec grep $str {} \; -exec mkdir $str \;
chmod 755 并双击它我得到:
Last login: Wed Apr 2 20:44:14 on ttys004
zipher:~ Rory$ /Users/Rory/Desktop/CD.command ; exit;
cd: \c
/Users/Rory/Desktop/Test
txt: \c
txt
然后它继续到go to hell in a handbasket,递归地进入另一个命令从未冒险过的地方——我必须 ^C 它因为它已经疯了。它也不会创建新目录.. 我在哪里screw the pooch?
【问题讨论】:
-
因此,如果您在树上的任何位置找到包含
$txt的文件,您只是想在当前工作目录中创建一个目录?
标签: macos bash shell unix terminal