I got stuck in the windows batch(cmd) pattern search. I need to search for a pattern in a file and need to return the line number. I have used FINDSTR
with /X
option, but it is also appending the patterned matched line to the line number.
Also I don't have privilege to install any utility like unix-utilities so that I can use cut
to extract the line number.
for /f "delims=:" %%a in ('findstr /n "pattern" "file"') do echo "pattern" found in line #%%a