Bash
2013-10-21 16:09
183 查看
(遇到时就更新)
①批量将文件编码由gb2312转为utf8:
②批量在文件开头添加文本内容:
③批量在文件末尾添加文本内容:
④批量替换多个文件中的字符串:
⑤批量修改文件名:
①批量将文件编码由gb2312转为utf8:
for filename in `find . -type f | xargs ls -l | awk '{print $8}'`;do echo $filename;iconv -f utf8 -t gb2312 $filename -o $filename;done
②批量在文件开头添加文本内容:
for filename in `find . -type f | xargs ls -l | awk '{print $8}'`;do echo $filename;sed -i '1i\the text need to add' $filename;done
③批量在文件末尾添加文本内容:
for filename in `find . -type f | xargs ls -l | awk '{print $8}'`;do echo $filename;sed -i '$a\the text need to add' $filename;done
④批量替换多个文件中的字符串:
sed -i "s/8080/8443/g" `grep 8080 -rl .`
⑤批量修改文件名:
ls -l conf* | awk '{filename=$8;gsub(/conf/,"config",$8);print "mv "filename " "$8}'|sh
相关文章推荐
- read line from file with bash shell script
- 右键 - 添加Git Bash Here菜单
- LINUX权限-bash: ./startup.sh: Permission denied
- shell用户配置详解及bash命令参数
- Linux:-bash: ***: command not found
- -bash: /bin/rm: Argument list too long
- zsh on windows 10 bash
- linux下提示bash:command not found
- bash语法之循环
- bash 编程中循环语句用法
- 51NOD 1070 Bash游戏 V4(斐波那契博弈)
- 为什么Linux登录后显示“-bash-3.2#”
- bash 中的 ${ # % : / } 使用
- 执行脚本出现bin/bash: bad interpreter: No such file or directory
- bash 实现多线程执行多个命令
- Linux下文件 ~/.bashrc 和 ~/.bash_profile 和 /etc/bashrc 和 /etc/profile 的区别 | 用户登录后加载配置文件的顺序
- Linux登录时/etc/profile、~/.bash_profile等几个文件的加载过程
- ubuntu下source、sh、bash、./执行脚本的区别
- linux笔记:shell基础-bash基本功能