Frequently-used Scripts
used scripts
2023-09-11 14:16:17 时间
-
for p in `find /root/epsilon -type d -a -iname vaspy -exec ls -ld {} \;|awk '{print $NF}'`;do mv $p `dirname $p`/epsilon_vasp;done
递归修改特定目录下所有某特定文件夹名字为新名字
-
for p in $(find /root/epsilon/ -type f -exec ls {} \;);do sed -i 's/vaspy/epsilon_vasp/gi' $p;done
递归修改特点目录下所有文件中的某特定内容
-
递归修改目录下所有文件和文件名
1 #!/bin/env sh 2 3 function changName(){ 4 new_name=$(echo $1|sed -r 's/(^.*$)/\1_ebb/gi') 5 #new_name=$(echo $1|sed -r 's/_ebb//gi') 6 printf "PROCEDURE:%-60s==> %s\n" $1 $new_name 7 if [[ $1 != $new_name ]];then 8 mv $1 $new_name 9 fi 10 } 11 12 function epsilon(){ 13 for p in `ls`;do 14 local old_name=$p 15 if [[ -d $p ]];then 16 cd $p 17 epsilon 18 changName $old_name 19 else 20 changName $p 21 fi 22 done 23 cd .. 24 } 25 26 27 if [[ -z $1 ]];then 28 ebb='.' && echo -e "\033[33;42mworking_dir: .\033[0m" 29 else 30 [[ -f $1 ]] && echo -e "\033[33;42mv $1 $1_ebb\033[0m" && mv $1 $1_ebb && exit 0 31 ebb=$1 && echo -e "\033[33;42mworking_dir: $ebb\033[0m" 32 fi 33 34 cd $ebb 35 36 epsilon
- 递归比较两个目录文件的不同
#!/bin/env sh if [ "$#" -eq 0 -o "$#" -eq 1 ];then echo -e "\e[4;1;36mThe Script is designed to find different files in two directories\nUsage:`basename $0` dir1 dir2\e[0m" exit 5 fi if [ ! -d $1 -o ! -d $2 ];then echo -e "\e[1;34m$1 and $2 must be directories\e[0m" exit 55 fi for b in {1..3};do eval tmp$b=`mktemp` # eval 做两次变量替换 done #diff <(cd "$1";find . |sort) <(cd "$2";find . |sort) > tmp (cd $1;find . | sort > $tmp1) # 相对目录时,不影响当前shell (cd $2;find . | sort > $tmp2) diff $tmp1 $tmp2 > $tmp3 echo -e "\e[7;43mOnly exists in $1:\e[0m" awk -F/ -v b=${1/%\/} '/</{ {printf("%s/",b)} for(m=2;m<=NF;m++){printf("%s/",$m)} {print ""} }' $tmp3 echo -e "\e[7;46mOnly exists in $2\e[0m" awk -F/ -v b=`echo $2|sed '{s@/*$@@}'` '/>/{ {printf("%s/",b)} for(m=2;m<=NF;m++){printf("%s/",$m)} {print ""} }' $tmp3 for b in `seq 1 3`;do eval rm -rf \$tmp$b # eval done
- 递归解压,分离文件
#!/bin/env sh IFS=$'\n' function extract(){ dir=`echo $1|sed -r 's/\.[^.]+$//'` if [[ $1 =~ \.zip$ ]];then if [ ! -d $dir ];then mkdir -- $dir fi printf "\e[7mPROCEDURE:%-120s==> %s\e[0m\n" $1 "dispose zip" unzip -o $1 -d $dir elif [[ $1 =~ \.rar$ ]];then if [ ! -d $dir ];then mkdir -- $dir fi printf "\e[7mPROCEDURE:%-120s==> %s\e[0m\n" $1 "dispose rar" rar x -y $1 $dir else printf "\e[7mPROCEDURE:%-120s==> %s\e[0m\n" $1 "don't need to dispose" fi } function copy(){ current_dir="$(cd -- "$(dirname "$0")";pwd)" prefix=$(echo $current_dir|sed 's#^/o/datum##') handbook="/y/handbook$prefix" diagram="/y/diagram$prefix" if [[ "$1" =~ 维修手册 ]];then if [[ ! -e "$handbook" ]];then mkdir -pv -- "$handbook" fi cp --no-clobber -- "$1" "$handbook" elif [[ "$1" =~ 电路图 ]];then if [[ ! -e "$diagram" ]];then mkdir -pv -- "$diagram" fi cp --no-clobber -- "$1" "$diagram" else #echo $1 does not qualify : fi } function epsilon(){ for p in `ls`;do local old_name=$p if [[ -d $p ]];then cd -- $p epsilon else copy $p fi done cd -- .. } if [[ -z $1 ]];then ebb='.' && echo -e "\033[33;42mworking_dir: .\033[0m" else [[ -f $1 ]] && echo -e "\033[33;42mv $1 $1_ebb\033[0m" && mv $1 $1_ebb && exit 0 ebb=$1 && echo -e "\033[33;42mworking_dir: $ebb\033[0m" fi cd -- $ebb epsilon
相关文章
- This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request.
- What is the yield keyword used for in C#?
- kentico中提示Message: An invalid SQL query was used.
- 【Bug】Lambda expression used inside Include is not valid
- can‘t be used as a mixin because it extends a class other than ‘Object‘.
- Vue - <transition> can only be used on a single element. Use <transition-group> for lists. 解决方案
- Variable used in lambda expression should be final or effectively final
- vue引入导航守卫报错error: 'to' is defined but never used (no-unused-vars)
- Qt error ------ incomplete type 'QApplication' used in nested name specifier
- keil5报错:* RESTRICTED VERSION WITH 0800H BYTE CODE SIZE LIMIT; USED: 08B5H BYTE (108%) *保姆级教程
- mongodb Sort operation used more than the maximum 33554432 bytes of RAM
- coco2dx新建项目报错,ld: -pie can only be used when targeting iOS 4.2 or later clang: error: linker command
- Flutter开发 - Multiple widgets used the same GlobalKey.
- 安装CocoaPods报错 - [!] The dependency `AFNetworking (~> 3.1.0)` is not used in any concrete target.
- This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.