Cut the last 2 characters of cmd.exe script response

I want to write a script that esentially pings another computer and gets average as number only. Right now I have a script that gets average ping as needed and shows it, but it has 'ms' prefix and I want to get rid of it. I can't seem to find cut equivalent (alright, I did found, but I can't make my existing script and it work together) that is already in Windows (it should be in cmd.exe by default).

My script:

FOR /F "usebackq skip=11 tokens=6 delims== " %i IN (`ping host2.internal`) DO @echo %i

I get: 197ms, but I need it to look like: 197.



Replace the DO part with

DO @set FOO=%i & echo %FOO:~0,-3%

This assigns the value of %i to a temporary variable FOO so that you can then use the substring extraction capability of the shell (SET /? for explanation). I am shaving off three characters instead of two because %i includes a trailing space.

This works here in Win 8: the -4 is required for occasions where IPV6 is also in force.

FOR /F "tokens=5 delims==<ms" %i IN ('ping -4 ^|find "Reply from"') DO @echo %i

Need Your Help

forms as html and pdf

c# html pdf

I would create many forms with different outputs but i wish to design the form only once.

Does clang or gcc take advantage of referencing restrictions for alias analysis

c++ gcc clang alias compiler-optimization

I am wondering if the alias analysis passes inside of clang or gcc treat C++ member reference variables differently than pointer variables. If the compiler could take advantage of some of the more

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.