M.frank
M.frank

Reputation: 145

Printing a specific line of a file in windows cmd

I am trying to print specific lines of a text file stored on my computer by using the Windows cmd.

For instance if I want to output line 17 of the textfile in the cmd, how is this possible? I have been using quite some time on this and I am running out of ideas.

Could you please help?

Regards

Magnus

Upvotes: 0

Views: 6274

Answers (1)

foxidrive
foxidrive

Reputation: 41234

@echo off
for /f "tokens=1,* delims=]" %%a in ('find /n /v "" ^< "myfile.txt" ^| findstr "^\[17\]" ') do set "variable=%%b"
echo "%variable%"

Upvotes: 1

Related Questions