Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是一批新人。我想我的问题对你来说很简单。我需要一个批处理脚本来计算从文件的第一行到包含在该文件中的唯一字符“A015”的行数(这个数字也应该考虑空白行)。谢谢你。
试试这个:
for /f "delims=:" %%i in ('findstr /n "A015" "file.txt"') do if not defined LineNumber set "LineNumber=%%i" if defined LineNumber (echo "A015" found at line %LineNumber%) else echo "A015" not found
如果文本文件中有多个“A015”,这将显示第一行号。