几个常用的shell脚本
2010-05-25 16:33
288 查看
a.批量处理文件名进行查找
: filemovescript
#!/bin/bash source_dir=$1 target_dir=$2 cd $source_dir for realfile in * do file=`echo $realfile | sed -e 's/ //g'` a=`echo $file | awk -F- '{print $1}'` b=`echo $file | awk -F- '{print $2}'` c=`echo $file | awk -F- '{print $3}'` mv_dir="$target_dir/$a/$b/$c" if [ ! -d $mv_dir ] ; then mkdir -p $mv_dir fi mv "$source_dir/$realfile" $mv_dir echo "mv "$source_dir/$realfile" $mv_dir" >> "$target_dir/move.log" done
b.批量文件查找
: find_seperate_move
#!/bin/bash cat $1 | while read line; do if [ -f "$line" ];then echo "fine $line" echo "find $line" >> "/move.log" echo "cp "$line" "$2"" >> "/move.log" cp "$line" "$2" else echo "can't find $line" echo "can't find $line" >> "/move.log" fi done
c.批量添加文件后缀
: file_add_suffix
#!/bin/bash source_file=$1 cat $source_file | while read line; do echo $line.rpm >> /result done
d.ftp批量下载
: ftp_filedownload_change.sh
#!/bin/bash ftp -nv<<! open (ip_address) user (user_name) (user_passwd) binary hash prompt off cd (ftp_dir) lcd (local_dir) mget * close bye !
e.批量删除后缀名
: delete_suffix.sh
#!/bin/bash for file in * do file=${file%.*} echo $file done
e.批量删除后缀名
: extrac_suffix.sh
#!/bin/bash for file in * do file=${file#*.} echo $file done | |
---|---|
相关文章推荐
- 常用的几个shell脚本_2_查看日志
- 常用的几个shell脚本_3_恢复工程
- 常用的几个shell脚本_4_更新jsp
- *Linux Shell 高级编程技巧4----几个常用的shell脚本例子
- 几个常用shell脚本命令
- 几个常用的shell脚本
- shell脚本常用的几个命令
- 常用的几个shell脚本_1_更新工程
- 几个常用的Linux系统性能监控shell脚本
- 常用的shell脚本
- 常用shell脚本命令总结(添加中。。。)
- 几个常用库在CMake中的设置脚本
- shell脚本中常用的命令:wget、curl、ss、lsof、nmap、nc、netstat、telnet
- shell脚本常用(1)
- 总结的常用shell脚本命令,以备后用。
- 常用shell脚本
- 几个常用的Linux操作系统监控脚本
- shell脚本几个常见问题
- shell的一些常用的语句(if语句,变量,for、while、until语句、函数调用、脚本调用)
- 几个常用的Linux操作系统监控脚本