#递归查找文件
find . -type f -name "*.c"
#替换当前目录及子目录下所有文件中的TAB字符为4个空格
# xargs -0 : 转义参数中的特殊字符
find . -type -f -print | xargs -0 sed -i "s/\t/ /g"
# xargs -I file 给参数取别名
find . -type -f -print | xargs -0 -I file sed -i "s/\t/ /g"file
#批量重命名文件,将bsp开头的文件名改为ft_cpu开头的文件名
for f in *.c; do mv "$f" $(echo "$f" | sed 's/^bsp/ft_cpu/g'); done
#查找git冲突文件,全部替换为远端库版本
egrep -rl "<<<<<<<" | xargs -0 git checkout --theirs
----------------------------------------------------正则表达式---------------------------------------
按行匹配,提取匹配项:
(?-s).*?Video\((\S+)\).*\R
/**
* 说明:
* (?-s) :关闭single-line(DOTALL)模式, DOT不能匹配换行符。
* \R : 匹配换行符
* 示例: Line 184: <a href="http://www.youtube.com/watch?v=zLP_X4wyHbY" title=" Video (zLP_X4wyHbY)"><div class="youtube_icon"> Video
*/