sar
sar

Reputation:

"The system cannot find the file" error while using SED

I am using sed to find total number of lines in a txt file. I want to assign the output of sed to a variable.

I used the following code to do this:

for /f %%a in (`"sed15 -n $= TEST.TXT"') do set linenum=%%a

and I get this error message:

the system cannot find the file `"sed15 -n $= TEST.TXT"'

How can I solve this?

Upvotes: 1

Views: 1295

Answers (2)

jpf
jpf

Reputation: 1475

Needs to know how to interpret backquotes:

for /f "usebackq" %%a in (`sed15 -n $= TEST.TXT`) do (set linenum=%%a)

Upvotes: 1

Sam Cogan
Sam Cogan

Reputation: 4334

It is looking for the file relative the the path you start the DOS command in. You can either give a full path for the file - c:\text.txt etc or start the command in the right directory.

Upvotes: 0

Related Questions