我有档案test.txt
class c1 {
___________ any text _____________
}
class c2 {
___________ any text _____________
}
class c3 {
___________ any text _____________
}
我编写 bash 脚本逐行扫描test.txt
并将每一行与正则表达式进行比较以获取包含类标题但不起作用的行:(
#!/bin/bash
while read line
do
if [[ "$line" =~ "class *\w+" ]]; then
echo $line
fi
done <test.txt
最终目标将文件中的每个类分开