在bash脚本中查找"缺少参数"错误

pg.*_*pg. -1 unix bash shell

我正在设置一个脚本,将svn add所有新的非subversion文件转换为subversion,然后进行提交.

#!/bin/bash
find /path/to/uploads -type f -mmin -5 -not -iwholename
'*.svn*'|xargs -r /usr/bin/svn add
sleep 2
/usr/bin/svn commit /path/to/uploads -m auto_upload
Run Code Online (Sandbox Code Playgroud)

当我从shell运行它时,我得到:

find: missing argument to `-iwholename'
upload_images.sh: line 3: *.svn*: command not found
Run Code Online (Sandbox Code Playgroud)

我是否需要摆脱星号或其他东西?我糊涂了.我在这做错了什么?

Fat*_*ror 5

你的find命令中间有一个换行符.这将导致bash将其解释为两个单独的命令.要么使它成为一条线:

find /path/to/uploads -type f -mmin -5 -not -iwholename '*.svn*'|xargs -r /usr/bin/svn add
Run Code Online (Sandbox Code Playgroud)

或使用a \继续它:

find /path/to/uploads -type f -mmin -5 -not -iwholename \
'*.svn*'|xargs -r /usr/bin/svn add
Run Code Online (Sandbox Code Playgroud)

听起来像是复制+粘贴错误.