编辑代码


#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
touch include.log
echo 'PerformanceDMS.  SuccessUtility.<Counters."1".csproj' >> include.log
echo 'PerformanceDMS. UtilitySuccess.<Counters."2".csproj' >> include.log
echo 'src/PerformanceDMS. FailUtility.<Counters."3".csproj' >> include.log
echo 'test/PerformanceDMS.Utility.Test.Counters."4".csproj' >> include.log

echo '
[grep "<Counters" include.log]-01:'
# 搜索出include.log中含有"<Counters"的所有行
grep "<Counters" include.log

echo '
[grep "<Counters" include.log]-02:'
# 接上述01的注释
# 把' '替换成'\n',一个' '替换成一个'\n',两个' '替换成两个'\n'
grep "<Counters" include.log | tr ' ' '\n'

echo '
[grep "<Counters" include.log]-03:'
# 接上述02的注释
# 以单个双引号为分隔符,逐行打印$0(本行内容)和$2(分割所得结果的第二个元素)
grep "<Counters" include.log | tr ' ' '\n' | awk -F'"' '{printf "$0="$0; print "; $2="$2}'

echo '
[grep "<Counters" include.log]-04:'
# 接上述03的注释
# 先过滤出行中包含Success的所有行,然后以单个双引号为分隔符,逐行打印$0(本行内容)和$2(分割所得结果的第二个元素)
# /Success/是正则表达式
grep "<Counters" include.log | tr ' ' '\n' | awk -F'"' '/Success/ {printf "$0="$0; print "; $2="$2}'