首页 > 系统服务 > 详细

shell脚本for实用(不定期更新)

时间:2015-04-30 10:50:53      阅读:304      评论:0      收藏:0      [点我收藏+]

1、实现sourse目录下部分文件(文件名以文本列表形式列出,文本文件名为list),复制到另外一个目录/opt/targe/下

#!/bin/bash
cd /opt/source 
for file in `cat /opt/source/list` ;
do
cp -r -n $file /opt/targe/
done

注:``在tab键上面 ,cp -n代表不覆盖。

扩展 scp -P 端口号 root@ip:/opt/source/  /opt/targe/


2、

#!/bin/bash
for str in 1 2 3 4 5
do
    echo -e "The value is: $str \n"
done

输出

The value is: 1 

The value is: 2 

The value is: 3 

The value is: 4 

The value is: 5
#!/bin/bash
for str in "1 2 3 4 5"
do
    echo -e "The value is: $str \n"
done

输出

The value is: 1 2 3 4 5


本文出自 “牧羊暗语” 博客,请务必保留此出处http://466716241.blog.51cto.com/1475798/1640762

shell脚本for实用(不定期更新)

原文:http://466716241.blog.51cto.com/1475798/1640762

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!