I want to reduce the Output of the following Line:
for /F "tokens=10" %a in ('c:\Programme\smartmontools\bin\smartctl.exe -a /dev/hdb ^| findstr /BC:" 9" ') do @echo %a
This line is extracting the Power-On-Hours Value from an HDD or SSD.
Most HDDs or SSDs give me the correct hours like: 3423 or something. Just the simple Value.
Unfortunately, some Kingston SSDs have the following Value: 197h+00m+00.000s
Is it possible to reduce the Output to 197 ?
Maybe with another findstr pipe?
The Command must be in the same line (!) like something: This does not work, but I hope it explains what I mean by that.
for /F "tokens=10" %a in ('c:\Programme\smartmontools\bin\smartctl.exe -a /dev/hdb ^| findstr /BC:" 9" | findstr [0-9][0-9]?[0-9]?[0-9]?[0-9]?') do @echo %a
Sorry for my bad english!!
findstr
can find a line containing a certain string, but it isn't able to modify the line.
You can add another for
to do what you want:
@for /F "tokens=10" %a in ('@c:\Programme\smartmontools\bin\smartctl.exe -a /dev/hdb ^| findstr /BC:" 9" ') do @for /f "delims=h" %b in ("%a") do @echo %b
(unverified, as I don't have this utility)