当前位置: 技术问答>linux和unix
如何将找出来的shell脚本执行一遍?
来源: 互联网 发布时间:2017-01-27
本文导语: find ./ -name clear.sh ////用find命令找出来的sh脚本,想依次执行一遍,该如何写? ./check_ssh_rsh/clear.sh ./check_interface_in_DB/clear.sh ./check_interface_link_in_DB/clear.sh ./check_port_num_in_Oracle/clear.sh ./check_port_num_in_Sybase/clear.sh ./chec...
find ./ -name clear.sh ////用find命令找出来的sh脚本,想依次执行一遍,该如何写?
./check_ssh_rsh/clear.sh
./check_interface_in_DB/clear.sh
./check_interface_link_in_DB/clear.sh
./check_port_num_in_Oracle/clear.sh
./check_port_num_in_Sybase/clear.sh
./check_Oracle_service/clear.sh
./check_business_DB/clear.sh
./check_crontab/clear.sh
./check_IP_info/clear.sh
./check_rcp_scp/clear.sh
./check_VxVM_version/clear.sh
./check_VCS_version/clear.sh
./check_OS_profile/clear.sh
./check_upgrade_check_tool/clear.sh
./check_SLS_hostname/clear.sh
./check_DB_server_name/clear.sh
./check_DB_IP/clear.sh
./check_IMAP_ROOT_space/clear.sh
./check_expand_space_DB/clear.sh
./check_bak_right/clear.sh
我之前只知道找到后ls -l 处理:
find ./ -name clear.sh -exec ls -l {} ;
-rwxrwxrwx 1 nobody nobody 113 Dec 20 11:04 ./check_ssh_rsh/clear.sh
-rwxrwxrwx 1 nobody nobody 113 Dec 20 11:05 ./check_interface_in_DB/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_interface_link_in_DB/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_port_num_in_Oracle/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_port_num_in_Sybase/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_Oracle_service/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_business_DB/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_crontab/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_IP_info/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_rcp_scp/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_VxVM_version/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_VCS_version/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_OS_profile/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_upgrade_check_tool/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_SLS_hostname/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_DB_server_name/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_DB_IP/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_IMAP_ROOT_space/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_expand_space_DB/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_bak_right/clear.sh
如果替换 find ./ -name clear.sh -exec ls -l {} ; 中 的ls -l ,让找到的*.sh执行一遍?谢谢!
./check_ssh_rsh/clear.sh
./check_interface_in_DB/clear.sh
./check_interface_link_in_DB/clear.sh
./check_port_num_in_Oracle/clear.sh
./check_port_num_in_Sybase/clear.sh
./check_Oracle_service/clear.sh
./check_business_DB/clear.sh
./check_crontab/clear.sh
./check_IP_info/clear.sh
./check_rcp_scp/clear.sh
./check_VxVM_version/clear.sh
./check_VCS_version/clear.sh
./check_OS_profile/clear.sh
./check_upgrade_check_tool/clear.sh
./check_SLS_hostname/clear.sh
./check_DB_server_name/clear.sh
./check_DB_IP/clear.sh
./check_IMAP_ROOT_space/clear.sh
./check_expand_space_DB/clear.sh
./check_bak_right/clear.sh
我之前只知道找到后ls -l 处理:
find ./ -name clear.sh -exec ls -l {} ;
-rwxrwxrwx 1 nobody nobody 113 Dec 20 11:04 ./check_ssh_rsh/clear.sh
-rwxrwxrwx 1 nobody nobody 113 Dec 20 11:05 ./check_interface_in_DB/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_interface_link_in_DB/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_port_num_in_Oracle/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_port_num_in_Sybase/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_Oracle_service/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_business_DB/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_crontab/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_IP_info/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_rcp_scp/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_VxVM_version/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_VCS_version/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_OS_profile/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_upgrade_check_tool/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_SLS_hostname/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_DB_server_name/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_DB_IP/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_IMAP_ROOT_space/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_expand_space_DB/clear.sh
-rwxr--r-- 1 nobody nobody 113 Dec 20 11:05 ./check_bak_right/clear.sh
如果替换 find ./ -name clear.sh -exec ls -l {} ; 中 的ls -l ,让找到的*.sh执行一遍?谢谢!
|
find . -name "*.sh" -exec sh {} ;
|
find ./ -name clear.sh | sh
|
直接一个pipe然后用shell执行即可,
执行这么多,还是小心为好
执行这么多,还是小心为好
|
不知用循环可以吗?
for i in ./*/clear.sh ; do sh i ; done
这会儿在Windows下,没有测试,你自己试一下
|
-exec就是干这个的啦
如果非常多,可以通过管道交给xargs
如果非常多,可以通过管道交给xargs
|
这个换上相应的执行命令不就行了么?