命令replace成bash脚本$ 1的值

我有这个简单的脚本来改变我的apache2网站的权限

/var/www/html# cat permissions_setup.sh chown -R root $1 chgrp -R www-data $1 chmod -R 750 $1 chmod g+s $1 

我在我的html/目录中有两个.sh shell脚本

 /var/www/html# ll total 40 drwxr-xr-x 8 root root 4096 Jul 5 16:45 ./ drwxr-xr-x 4 root root 4096 Jun 13 18:37 ../ drwxr-s--- 5 root www-data 4096 Jun 6 18:17 foo.com/ drwxr-s--- 5 root www-data 4096 Jun 13 18:52 bar.org/ drwxr-xr-x 5 root root 4096 Jun 13 18:13 barfoo.com/ -rwxr-xr-x 1 root root 67 Jul 5 16:44 permissions_setup.sh* drwxr-xr-x 5 root root 4096 Jun 13 18:42 foobar.com/ -rwx------ 1 root root 1163 Jun 13 18:41 website_add.sh* 

我已经在两个网站上运行了脚本。 我试图在其他网站上使用命令replace,如:

 /var/www/html# ./permissions_setup.sh $(ls -I "*.sh") 

要么

 /var/www/html# ls -I "*.sh" $(./permissions_setup.sh) chown: missing operand after 'root' Try 'chown --help' for more information. chgrp: missing operand after 'www-data' Try 'chgrp --help' for more information. chmod: missing operand after '750' Try 'chmod --help' for more information. chmod: missing operand after 'g+s' Try 'chmod --help' for more information. 

但是这两个命令都没有改变所有网站的权限。 我对编辑脚本不感兴趣。 我能在这种情况下使用命令replace吗?

由于您不想编辑脚本:

 for f in $(ls -I "*.sh"); do ./permissions_setup.sh $f; done;